Javascript and cookies

0 comments

hi programmers!

I have this simple HTML form just for testing purposes.

<form id = “myform” onsubmit = “return checkcheckboxes()”>

Box 1<input type = “checkbox” name = “chk1”>

Box 2<input type = “checkbox” name = “chk2”>

Box 3<input type = “checkbox” name = “chk3”>

<input type = “submit” value = “Go to the next task”>

<span id = “message”>congratulations! you have completed all the tasks completely</span>

</form>

<script type = “text/javascript”>

function checkcheckboxes() {

document.getElementById(“message”).innerHTML = “”;

var valid = true;

var f = document.getElementById(“myform”);

if (f.chk1.checked == false) {valid = false}

if (f.chk2.checked == false) {valid = false}

if (f.chk3.checked == false) {valid = false}

if (!valid) {document.getElementById(“message”).innerHTML = “You must check all three boxes to proceed”};

return valid;

}

</script>

Now i wanna do 2 things

  • when a submit button is clicked, it sends the user to the next task(link)
  • i also wana trigger a cookie, so when they complete one task, the information is saved on the cookie, and when the user closes the window or get back to it later, task 2 will be showing up not task 1(every task has a different link)


About the Author

Follow me


{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}