/    Sign up×
Community /Pin to ProfileBookmark

Adding data to textfile doesn’t work

Hi, i’m working on a simple website to register items, but I got some code that just doesn’t work whatever I try.

“`
<!DOCTYPE html>
<html>
<head>
<script>
function WriteToFile(passForm)
{
var fso = CreateObject(“Scripting.FileSystemObject”);
var s = fso.CreateTextFile(“/voorraad.txt”, True);
var p = document.getElementById(‘product’);
var a = document.getElementById(‘aantal’);
var d = new Date(year, month, day, hours, minutes, seconds);
s.writeline(d);
s.writeline(p);
s.writeline(“Aantal: ” + a);
s.writeline(“—————————–“);
s.Close();
}
</script>
</head>
<body>

<form onSubmit=”WriteToFile(this)”>
<label>Product: </label>
<input type=”text” name=”product” id=”product” size=”20″>
<br>
<label>Aantal: </label>
<input type=”text” name=”aantal” id=”aantal” size=”20″>
<input type=”submit” value=”submit”>
</form>

</body>
</html>
“`

When I click on the submit button, the website reloads with /?product=test&aantal=test2 at the end of the url (I wrote test and test2 in the textboxes. Does anyone see what I’m doing wrong here? Or am I missing some things? The textfile is on the right location but it’s always empty whatever I try…

to post a comment
HTMLJavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@AloizychJan 17.2020 — tag br
Copy linkTweet thisAlerts:
@Patrick006Jan 19.2020 — Do You know what could be problem? Thanks.

[url=https://www.baloune.com/guide-sante-chiens/] assurance chien [/url]
×

Success!

Help @jaimy spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.25,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...