Javascript and cookies

User Generated

te8_obv52

Programming

Description

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)


User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Explanation & Answer

This can be easily achieved in Jquery? Do you want to use Jquery? I can answer this for $3


Anonymous
I was stuck on this subject and a friend recommended Studypool. I'm so glad I checked it out!

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4