words
Question: JavaScript/Cookies help Hello, I am working with javascript for html5, and this assignment requires use of js and cookies. I've written out the JS and
JavaScript/Cookies help
Hello, I am working with javascript for html5, and this assignment requires use of js and cookies. I've written out the JS and it works to an extent. The cookies are not stored on firefox and my results do not display, this is the JS File.
function survey() { window.alert("Hello there! Thank you for taking our survey!"); var myResults = ""; if (window.confirm("Are you Ready?")) { var myArray = new Array(); myArray[0] = prompt("What is your first name?"); myArray[1] = prompt("What is your last name?"); window.alert("Thank you " + myArray[0] + "For the next few questions, please hit Okay or Cancel");
myArray[2] = confirm(myArray[0] + ", Do you plan to sell any food items?"); myArray[3] = confirm(myArray[0] + ", Do you plan to sell any clothing items?"); myArray[4] = confirm(myArray[0] + ", Do you plan to sell any electronics?"); myArray[5] = confirm(myArray[0] + ", Do you plan to sell any home office supplies?"); myArray[6] = confirm(myArray[0] + ", Do you plan on selling any miscellaneous items?"); myArray[7] = confirm(myArray[0] + ", Do you plan on buying items?");
//cookie list myCookieList = "First Name=" + myArray[0] + ";" + "Last Name=" + myArray[1] + ";" + "Food items=" + myArray[2] + ";" + "Clothing=" + myArray[3] + ";" + "Electronics=" + myArray[4] + ";" + "Home Office Supplies=" + myArray[5] + ";" + "Miscellaneous=" + myArray[6] + ";" + "Buying?=" + myArray[7] + ";";
//splitting cookies for (var i = 0; i < cookieListArray.length - 1; i++) { name = cookieListArray[i].split('=')[0]; value = cookieListArray[i].split('=')[1]; myResults += name + ": " + value + " "; var cookieEnabled = (navigator.cookieEnabled) ? true : false; if (cookieEnabled == true) { window.alert("You have cookies"); document.cookie = "favorite_toy=nerf"; document.cookie = (name + "=" + value); } else if (cookieEnabled == false) { window.alert("Cookie not enabled"); } } document.getElementById("results").innerHTML = myResults; } else { window.alert("I\'m sorry. You can come back anytime to complete our survey."); document.getElementById("results").innerHTML = myResults; } }
Nothing relating to cookies displays.
//////////////////////////html//////////////
Hello, class!
Learn more »
/////////////////////////////////////////////////////css
body { padding-top: 50px; padding-bottom: 20px; } .navbar{ background-color:red; -webkit-animation-name:colorbar; -webkit-animation-duration:3s; -webkit-animation-iteration-count:infinite; } @keyframes colorbar{ 25%{background-color:red;} 50%{background-color:pink;} 75%{background-color:red;} 100%{background-color:pink;}
}
div.jumbotron{ background-color:lightpink; } thead th{ text-align:left; background:red; color:white; border:solid black; } tbody th{ text-align:center; background:red; border:solid black; } tbody td{ border: thin solid black; font-weight:bold; text-align:center; } td img{ width:100px; height:100px; } label { background-color:pink; } #fruit { color: white; border: medium solid black; background-color: lawngreen; padding: 4px; font-size:x-large; } #fruit:hover{ font-size: xx-large; border: medium solid white; background-color: pink; color:black; padding:4px; -webkit-transition-delay:100ms; -webkit-transition-property:background-color, color, padding,font-size,border; -webkit-transition-duration: 500ms; }
@font-face{ font-family:'Acme'; font-style: normal; font-weight: normal; } h1{ font-family: 'Acme', sans-serif; text-shadow: 2px 2px green; } ul#fruitlist{ font-size:20px; border: dashed black; background-color:white; -webkit-column-count:3; -webkit-column-rule: 2px solid red; } ul img{ height: 100px; width:100px; } div.row{ border:medium solid black; background-color:grey; box-shadow: 10px 10px black; } div h2{ color:red; border: medium double black; border-color:pink; background-color:black; text-shadow: 1px 1px white; } #durian::first-letter{ font-family:'Comic Sans MS'; color:seagreen; font-size:xx-large; } #durian{ -webkit-column-count:3; -webkit-column-rule:3px dotted black; } p img{ height:100px; width:100px; } /* adjacent selector, the p part following h2 should turn yellow*/ h2 + p { color: yellow; }
.retailprice{ text-decoration: line-through; color: red; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
