I need to append the data entered in a form on a webpage into a txt file called "text.txt". I'm not sure what the issue is but my knowledge of jscript is very limited.
<html>
<head>
<title>Form</title>
<script>
function Write(Forename, Surname)
{
var fso, f, r;
var ForReading = 1, ForWriting = 8;
fso = new ActiveXObject("Scripting.FileSystemObject");
f = fso.OpenTextFile("text.txt", ForWriting, true);
f.Write(Forename + Surname);
f.Close();
}
</script>
</head>
<form onSubmit="Write(this['Forename'].value, this['Surname'].value)">
<input type="text" name="Forename" id="Forename" value="Forename" size="20">
<input type="text" name="Surname" id="Surname" value="Surname" size="20">
<input type="submit" value="Add Person">
</form>
</html>
there is a file called "text.txt" in the same folder
ActiveXObjectwhich is only supported by Internet explorer. As this browser is dead, you should not rely on that.falsefromonSubmitattribute, then this will work in IE (only), if you've allowed to create ActiveXObjects in Intranet Zone security settings.