1

So, I've copied this code and tried to run it. It supposed to take the input (in this case, name) and save it into a text file. But, it didn't work as I expected, can someone tell me what's wrong with this code?

<!DOCTPYE html>

<head>
<title>Web test</title>
</head>

<body>
<form onSubmit="WriteToFile(this)">
    <label>Name please: </label>
    <input type="text" name="nname" id="fname" size="18">
    <br>
    <br>
    <input type="submit" value="submit"> 
</form>
<script>
    function WriteToFile(passForm){
    set fso = CreateObject("Scripting.FileSystemObject");
    set s = fso.CeateTextFile("test.txt", True);
    var firstName = document.getElementById('fname');
    s.writeline(firstName);
    s.writeline("");
    s.Close();
    }
</script>
</body>
<html>
Darwish
  • 49
  • 5
  • This way is no longer work. Try using `Blob` instead. https://stackoverflow.com/a/35548142/13396863 – Miheo Feb 01 '21 at 06:39

1 Answers1

1

There's a misspelling here var firstName = document.geteElementById('fname'); it's supposed to be var firstName = document.getElementById('fname');

ObscurusLux
  • 370
  • 3
  • 14
  • Yeah, I noticed the misspelling right after I posted this question, but it is still not working after I changed it – Darwish Feb 01 '21 at 04:33
  • it's supposed to be var firstName = document.getElementById('fname').value; try changing it back – ObscurusLux Feb 01 '21 at 04:39