Sample Javascript to insert form values
|
Top Previous Next |
<SCRIPT TYPE="text/javascript">
|
//
|
// This block of code extracts the <site> and <date> variables
|
//
|
|
var var1 = location.search.substring(1, location.search.length)
|
|
// replace %20's with spaces so they're readable
|
while (var1.indexOf("%20") != -1)
|
{
|
var index = var1.indexOf("%20")
|
var first = var1.substring(0,index)
|
var last = var1.substring(index+3,var1.length)
|
var1 = first + " " + last
|
}
|
|
// replace %26 with the & so we can find it
|
while (var1.indexOf("%26") != -1)
|
{
|
var index = var1.indexOf("%26")
|
var first = var1.substring(0,index)
|
var last = var1.substring(index+3,var1.length)
|
var1 = first + "&" + last
|
}
|
|
// extract the two parameters
|
myparams = var1.split("&")
|
var param1 = ""
|
var param2 = ""
|
if (myparams.length > 0) { var param1 = myparams[0] }
|
if (myparams.length > 1) { var param2 = myparams[1] }
|
|
// see if it's in "May 23, 2005" format
|
|
dateparts2 = param2.split(",")
|
if (dateparts2.length == 2)
|
{
|
dateparts3 = dateparts2[0].split(" ")
|
if (dateparts2.length == 2 && dateparts3.length == 2)
|
{
|
mon = dateparts3[0]
|
day = dateparts3[1]
|
year = dateparts2[1]
|
if (year.length == 3 || year.length == 5)
|
{ year = year.substring (1, year.length) }
|
if (year.length == 4 && year.substring(0,2) == "20")
|
{ year = year.substring(2,4) }
|
|
if (mon.substring(0,3) == "Jan") { mon = "1"}
|
if (mon.substring(0,3) == "Feb") { mon = "2"}
|
if (mon.substring(0,3) == "Mar") { mon = "3" }
|
if (mon.substring(0,3) == "Apr") { mon = "4" }
|
if (mon.substring(0,3) == "May") { mon = "5" }
|
if (mon.substring(0,3) == "Jun") { mon = "6" }
|
if (mon.substring(0,3) == "Jul") { mon = "7" }
|
if (mon.substring(0,3) == "Aug") { mon = "8" }
|
if (mon.substring(0,3) == "Sep") { mon = "9" }
|
if (mon.substring(0,3) == "Oct") { mon = "10" }
|
if (mon.substring(0,3) == "Nov") { mon = "11" }
|
if (mon.substring(0,3) == "Dec") { mon = "12" }
|
|
param2 = mon + "/" + day + "/" + year
|
}
|
}
|
|
</SCRIPT>
|
Site Requested:
|
<SCRIPT>
|
document.write('<input type="text" name="Site_Name" value ="' + param1 + '">')
|
</SCRIPT>
|
<NOSCRIPT>
|
<input type="text" name="Site_Name">
|
</NOSCRIPT>
|
Arrival Date:
|
<SCRIPT TYPE="text/javascript">
|
document.write('<input type="text" name="First_Night" value ="' + param2 + '">')
|
</SCRIPT>
|
<NOSCRIPT>
|
<input type="text" name="First_Night">
|
</NOSCRIPT>
|
(MM/DD/YYYY)
|