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
New contributor
Reshaun is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1