I have a simple HTML like this:
<html>
<head><title></title></head>
<body>
<script>var testVariable = "Hello"</script>
<form method="post" action="/">
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>
And my Node.js looks like this:
app.post('/', function(req, res) {
Console.log(req.body.testVariable);
});
What I need to do is when the form is submitted the testVariable
needs to be passed to the Node.js function, I'm trying with hidden fields but I'm still having problems with that, i.e:
<input type="hidden" name="chat" value="<script>testVariable</script>">
But as you can imagine it pass all the script as a string, and not the value of the variable.
Does someone knows how to do that? Sorry if this is a silly question, I'm new to JavaScript and Node.js in general and I can't find answers in Google.
Thanks.
Aucun commentaire:
Enregistrer un commentaire