In all cases with JavaScrip, it is best put in the HEAD or the HTML page
if you look in the editor at the source, you will find code like
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Booking Page</title>
<script type="text/javascript">
<!--
function urlGet(f){
var str = location.search.slice(1).split("&"), retVal = [], f = f || false;
for(p=0; p<str.length; p++){
// get the values.
if( str[p].indexOf("=") > 0 ){
var pv = str[p].split("=");
retVal[ pv.shift() ] = pv.pop();
}
}
return f ? retVal[f] : retVal;
}
//-->
</script>
Your scripts should be placed in the <HEAD> section of the document.
Your sending page form will need the form element to be set to GET
<form name="myform" action="booking.html" method="GET">
Your browser on the sending page will write the URL automatically on submit.
So your receiving page will need the function to access the field data in the URL.
So use of the function in the script
passedData = urlGet(); // grabs the data in the URL
will grab all that was passed as data and it is represented as an associative array of elements.
So... passedData['firstDate'] will return the value found in the URL for that element.
You quote the following
"car" - select box
"firstDate" - Text box
"time1" - select box
"secondDate" - text
"time2" - select
"days" - text
"rentalamount" - text
which equates to a URL like...
?car=selectedElement&firstDate=Text&time1=selectedElement&secondDate=text&time2=selectedDate&days=text&rentalamount=text
IMHO, you would be better off calculation the time and date references in the sending page, all JS times are expressed in milliseconds, so passing that value as a parameter in a URL you could reduce your URL to
car=carMake&firstDate=timeInMilliseconds&secondDate=timeInMilliseconds&days=days&rentalamount=amounttocharge
All dates and times boil down to milliseconds therefore passing dates and times can be replaced by a reference which will be in milliseconds.
The receiving script would only need to return a numeric value in to a date object to reconstruct the booking dates and times.
dateString = new Date( urlGet('firstDate')-0 ).toUTCString();
would return a date based on the number of milliseconds passed as a parameter. This method would reduce the need to escape date values in URLs.
To recap...
Your sending page calls the recieving page, as it ia a GET operation the data is automatically passed in the URL as a parameter.
Your receiving page uses a function to help you pull values and data from the URL.
I hope that clears some of the mystery up.