I have a form that should save what the user inputs into the form fields using cookies. However I've been doing a lot of research and I'm just not understanding how to apply cookies to my form. UGH! Here are the directions to the assignment "Create a document with a form for reserving a rental car. As a user creates a reservation, store cookies containing the user’s reservation information, including name and address, telephone, pickup and return dates, and car type. Also, create a button that redisplay a user’s reservation information with an alert message. Set the cookies so that they expire one day after a visit. Save the document as CarRentals. html."
And here is my code
<!DOCTYPE Public>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" media="all">
<link href="http://fonts.googleapis.com/css?family=Open+Sans+Condensed:300,400" rel="stylesheet" type="text/css">
<link href="http://fonts.googleapis.com/css?family=Open+Sans:300,400" rel="stylesheet" type="text/css">
<title>Rental Car Reservation</title>
</head>
<body>
<script type = "text/javascript">
function SaveInformation() {
localStorage.formInfo = document.getElementByID("select").value;
document.option = localStorage.formInfo;
}
function Submit() {
var form = document.register;
if (form.fname.value == "First Name"
|| form.lname.value == "Last Name"
|| form.address.value == "Address"
|| form.address.value == ""
|| form.telephone.value == "(555)555-5555"
|| form.pickupdate.value == "MM/DD/YYYY"
|| form.returndate.value == "MM/DD/YYYY"
|| form.cartype.value == "ex. Acura, Nissan, Ford etc."
|| form.classificationselection.value == "") {
return false;
}
else
return true;
}
function Reset(){
window.alert("Are you sure you would like to reset all fields?");
}
</script>
<h1>Rental Car Reservation Page</h1>
<form name="register" method="get" onsubmit="return Submit(); return Save Information()" onreset="return Reset()" action="FormProcessor.html">
<h3>Personal Information</h3>
<form method="post">
Name:<br>
<input type="text" name="fname" placeholder="First Name" pattern="[a-zA-Z]{2,15}" required/>
<input type="text" name="lname" placeholder="Last Name" pattern="[a-zA-Z]{2,15}" required/>
<br>
Address:<br>
<input name="address" placeholder="Address" required/>
<br>
Phone Number:<br>
<input name="telephone" placeholder="555-555-5555" pattern="\d{3}[\-]\d{3}[\-]\d{4}"/>
<br>
<h3>Reservation Information</h3>
Pickup Date:<br>
<input type="text" name="pickupdate" placeholder="MM/DD/YYYY" pattern="(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d" required/>
<br>
Return Date:<br>
<input type="text" name="returndate" placeholder="MM/DD/YYYY" pattern="(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d" required/>
<br>
Car Type:<br>
<input name="cartype" placeholder="ex. Acura, Nissan, Ford etc." required/>
<br>
Car Classification:<br>
<select name="classificationselection" id="select" required><br>
<option value=0>Compact</option>
<option value=1>Sedan</option>
<option value=2>Sports</option><br>
<option value=3>Luxury</option><br>
<option value=4>Wagon</option><br>
<option value=5>Muscle</option><br>
<option value=6>Supercar</option><br>
<option value=7>SUV</option><br>
<option value=8>Van</option><br>
<option value=9>Convertable</option><br>
</select><br>
<input type="submit" value="Submit"/>
</body>
</html>