Hi,
I am building a site and i need to move the contents from one form to another on a different page. The code i have used worked fine when i was testing, but since i put it on my live site i get syntax errors which i think is because of the '<' sign. The problem is, i havent got a clue what is wrong so your help is appreciated. Below is my code with the form and javascript to get the values from the URL.
<a name="details"></a>
<div class="box">
<div class="header">
<div class="h1">
<h1>Your Details</h1>
</div>
</div>
<div class="content">
<div id="webform-client-form">
<form method="POST" name="contactform" action="contact-form-handler.php">
<table>
<tr>
<td><label for="typecover">Type of Cover:</label></td>
<td colspan="3"><div class="select"><select id="typecover" name="typecover">
<option value="PersonalLifeInsurance">Personal Life Insurance</option>
<option value="IncomeProtection">Income Protection</option>
<option value="FamilyProtection">Family Protection</option>
</select></div></td>
</tr>
<tr>
<td><label for="policy">Policy is for:</label></td>
<td colspan="3"><div class="select"><select id="policy" name="policy">
<option value="Joint">Joint</option>
<option value="Individual">Individual</option>
</select></div></td>
</tr>
<tr>
<td><label for="smoker">Smoker:</label></td>
<td><div class="small-select"><select id="smoker" name="smoker">
<option value="No">No</option>
<option value="Yes">Yes</option>
</select></div></td>
<td><div class="label"><label for="year">Birth Year:</label></div></td>
<td><div class="small-select"><select id="year" name="year">
<option value="1986">1986</option>
<option value="1987">1987</option>
</select></div></td>
</tr>
</table>
<div class="input"><input type="submit" value="CONTACT US"></div>
</form>
</div>
<div class="waxseal">
</div>
</div>
</div>
<script type="text/javascript">
function replace(string,text,by) {
// Replaces text with by in string
var i = string.indexOf(text), newstr = '';
if ((!i) || (i == -1))
return string;
newstr += string.substring(0,i) + by;
if (i+text.length < string.length)
newstr += replace(string.substring(i+text.length,string.length),text,by);
return newstr;
}
var passed = replace(replace(location.search.substring(1),"+"," "),"=","&");
function split(string,text) {
var strLength = string.length, txtLength = text.length;
if ((strLength == 0) || (txtLength == 0)) return;
var i = string.indexOf(text);
if ((!i) && (text != string.substring(0,txtLength))) return;
if (i == -1) {
splitArray[splitIndex++] = string;
return;
}
splitArray[splitIndex++] = string.substring(0,i);
if (i+txtLength < strLength)
split(string.substring(i+txtLength,strLength),text);
return;
}
</script>
<script type="text/javascript">
function split(string,text) {
splitArray = string.split(text);
splitIndex = splitArray.length;
}
</script>
<script type="text/javascript">
var splitIndex = 0, splitArray = new Object();
split(passed,'&');
for (var i=0; i < splitIndex; i=i+2){
if (splitArray[i] == 'typecover')
document.contactform.typecover.value = unescape(splitArray[i+1]);
if (splitArray[i] == 'policy')
document.contactform.policy.value = unescape(splitArray[i+1]);
if (splitArray[i] == 'smoker')
document.contactform.smoker.value = unescape(splitArray[i+1]);
if (splitArray[i] == 'year')
document.contactform.year.value = unescape(splitArray[i+1]);
}
</script>