PDA

View Full Version : Submit button to save locally


m00gzilla
03-13-2006, 05:13 PM
Hello all

I'm creating a browser based form. It will be used in IE but not actually online. So anyway, what I am trying to accomplish is once the form is filled out and the submit button is pressed, I want the results to be saved as either a text document or a file for Excel, (.csv?) and saved into a folder on the machine. I'm assuming this is possible and realize it may not all be able to be accomplished with HTML alone, but any ideas would be greatly appreciated.

I already have the form created and a submit button. I really just need to know how to set the submit button to save results to a folder.

thanks
m00g

_Aerospace_Eng_
03-13-2006, 05:32 PM
What languages can you use? I'm not sure if you will be able to write to the desktop unless you use a .hta program. Then there are activex controls you can use to create a file on a local system. This will only work on Windows inside of a file with a .hta extension.

YourApplication.hta
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<script type="text/javascript">
var name;
var password;
var filename = "results.txt";
function WriteToFile()
{
var filename = "results.txt";
var fso = new ActiveXObject("Scripting.FileSystemObject");
if (fso.FileExists(filename))
{
var a, ForAppending, file;
ForAppending = 8;
file = fso.OpenTextFile(filename, ForAppending, false);
file.WriteLine(document.forms[0].name.value);
file.WriteLine(document.forms[0].password.value);
}
file.Close();
}
function ReadFromFile()
{
var fso, a, ForReading;
ForReading = 1;
fso = new ActiveXObject("Scripting.FileSystemObject");
file = fso.CreateTextFile(filename, ForReading, false);
file.Close();
WriteToFile();
return false;
}
</script>
</head>

<body>
<form action="#" method="post" onsubmit="return ReadFromFile();">
<input type="text" name="name">
<input type="password" name="password">
<input type="submit" value="Submit">
</form>
</body>
</html>
No browser currently allows this to work through the browser however an hta file will allow you to use it.

m00gzilla
03-13-2006, 07:30 PM
what is an .hta file?

_Aerospace_Eng_
03-13-2006, 07:40 PM
Its like an application that uses the Internet Explorer shell but it takes away all of the security warnings. It can only be ran locally on windows.

m00gzilla
03-13-2006, 09:06 PM
great! thats exactly what I am looking for.