93
rated 0 times
[
94]
[
1]
/ answers: 1 / hits: 42402
/ 9 Years ago, sun, may 24, 2015, 12:00:00
I am trying to make a username cookie using the user's input to a web form. However it's not working and I don't know why. Do you know what the problem is?
<form>
<input type="text" value="Enter Your Nickname" id="nameBox">
<input type="button" value="Go!" id="submit" onClick="setCookie();">
<form>
<script>
var today = new Date();
var expiry = new Date(today.getTime() + 30 * 24 * 3600 * 1000); // plus 30 days
function setCookie(name, value){
document.cookie=name + "=" + escape(value) + "; path=/; expires=" + expiry.toGMTString();
}
//this should set the UserName cookie to the proper value;
function storeValues(form){
setCookie("userName", form.submit.value);
return true;
}
</script>
</body>
More From » forms