javascript assignment it needs At least one form with at lea
javascript assignment it needs: At least one form with at least three different types of controls on the form (textbox, radio buttons, check boxes, submit/reset button). Data validation for the form Three or more functions Cookies - Select three items on the form and build cookies that will last for 7 months Some of the date methods Some animation would be nice setInterval() or setTi
Solution
<!DOCTYPE html>
 <html>
 <head>
 <script>
function storeCookie(cname,cvalue,exdays) {
 var d = new Date();
 d.setTime(d.getTime() + (exdays*24*60*60*1000));
 var expires = \"expires=\" + d.toGMTString();
 var c_value = document.getElementById(\"first_name\").value;
 document.cookie = \"c_name\" + \"=\" + c_value + \";\" + expires + \";path=/\";
 return false;
 }
function getCookie(cname) {
 var name = cname + \"=\";
 var ca = document.cookie.split(\';\');
 for(var i = 0; i < ca.length; i++) {
 var c = ca[i];
 while (c.charAt(0) == \' \') {
 c = c.substring(1);
 }
 if (c.indexOf(name) == 0) {
 return c.substring(name.length, c.length);
 }
 }
 return \"\";
 }
function checkCookie() {
 var user=getCookie(\"c_name\");
 if (user != \"\") {
 //document.write(\"I got your First name from a cookie!: \" + user);
 var text = document.createTextNode(\"I got your First name from a cookie!: \" + user);
 var child = document.getElementById(\'childDiv\');
 child.parentNode.insertBefore(text, child);
 }
 return false;
 }
</script>
 </head>
 <body>
 <form onsubmit=\"return storeCookie()\">
 First name:<br>
 <input type=\"text\" name=\"firstname\" id=\"first_name\">
 <br>
 <br>
 Gender:<br>
 Male <input type=\"radio\" name=\"gender\" value=\"MALE\"> <br>
 Female <input type=\"radio\" name=\"gender\" value=\"FEMALE\"> <br>
 Other <input type=\"radio\" name=\"gender\" value=\"OTHER\"> <br>
 <br><br>
 <input type=\"submit\" value=\"Store Cookie\">
   
 </form>
 <button onclick=\"checkCookie()\">Display Cookie</button>
 <div id=\"childDiv\"> </div>
 <div class=\"results\"></div>
 </body>
 </html>


