HI Guys
I have a simple check box form (using GET as the method) with a list of 10 different UK counties. I have validated the form so that users have to select no more and no less than 5 UK counties.
The validation works fine. However, when the form is posted to my next page (myresults.asp) , I need the values of the options to output the following in my url, no matter what UK counties they choose or what order they select them in:
I WANT:
"www.mysite .com/myresults.asp?c ounty1=London&c ounty2=Oxford&c ounty3=Leeds&co unty4=Mancheste r&county5=Liver pool"
INSTEAD OF
"www.mysite .com/myresults.asp?c heckbox=London& checkbox=Oxford &checkbox=Leeds &checkbox=Manch ester&checkbox= Liverpool"
You can view my full script below. If you have any ideas then that would be great.
I look forward to hearing from you
Rod from the UK
--------------SCRIPT--------------
<script Language="JavaS cript">
<!--
function checkbox_checke r()
{
var checkbox_choice s = 0;
for (counter = 0; counter < checkbox_form.c heckbox.length; counter++)
{
if (checkbox_form. checkbox[counter].checked)
{ checkbox_choice s = checkbox_choice s + 1; }
}
if (checkbox_choic es > 5 )
{
msg="You're limited to only three selections.\n"
msg=msg + "You have made " + checkbox_choice s + " selections.\n"
msg=msg + "Please remove " + (checkbox_choic es-5) + " selection(s)."
alert(msg)
return (false);
}
if (checkbox_choic es < 5 )
{
alert("Please select 5 counties. \n" + checkbox_choice s + " entered so far.")
return (false);
}
alert(" *** Thank you for your selection. ***");
return (true);
}
-->
</script>
<form method="get" action="http://www.mysite.com/myresults.asp" onsubmit="retur n checkbox_checke r()" name="checkbox_ form">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td width="20%" valign="top">
<input type="checkbox" value="Oxford" name="checkbox" >Anglesey<br>
<input type="checkbox" value="Liverpoo l" name="checkbox" >Avon<br>
<input type="checkbox" value="Bedfords hire" name="checkbox" >Bedfordshire<b r>
<input type="checkbox" value="Berkshir e" name="checkbox" >Berkshire<br >
<input type="checkbox" value="London" name="checkbox" >Borders<br>
<input type="checkbox" value="Buckingh amshire" name="checkbox" >Buckinghamshir e<br>
<input type="checkbox" value="Cambridg eshire" name="checkbox" >Cambridgeshire <br>
<input type="checkbox" value="Manchest er" name="checkbox" >Central<br>
<input type="checkbox" value="Cheshire " name="checkbox" >Cheshire<br>
<input type="checkbox" value="Clevelan d" name="checkbox" >Cleveland<br >
<input type="checkbox" value="Leeds" name="checkbox" >Clwyd<br>
</td>
</tr>
</table>
<p align="center">
<input type="submit" value="Compare Counties">
</form>
----------SCRIPT END-----------
I have a simple check box form (using GET as the method) with a list of 10 different UK counties. I have validated the form so that users have to select no more and no less than 5 UK counties.
The validation works fine. However, when the form is posted to my next page (myresults.asp) , I need the values of the options to output the following in my url, no matter what UK counties they choose or what order they select them in:
I WANT:
"www.mysite .com/myresults.asp?c ounty1=London&c ounty2=Oxford&c ounty3=Leeds&co unty4=Mancheste r&county5=Liver pool"
INSTEAD OF
"www.mysite .com/myresults.asp?c heckbox=London& checkbox=Oxford &checkbox=Leeds &checkbox=Manch ester&checkbox= Liverpool"
You can view my full script below. If you have any ideas then that would be great.
I look forward to hearing from you
Rod from the UK
--------------SCRIPT--------------
<script Language="JavaS cript">
<!--
function checkbox_checke r()
{
var checkbox_choice s = 0;
for (counter = 0; counter < checkbox_form.c heckbox.length; counter++)
{
if (checkbox_form. checkbox[counter].checked)
{ checkbox_choice s = checkbox_choice s + 1; }
}
if (checkbox_choic es > 5 )
{
msg="You're limited to only three selections.\n"
msg=msg + "You have made " + checkbox_choice s + " selections.\n"
msg=msg + "Please remove " + (checkbox_choic es-5) + " selection(s)."
alert(msg)
return (false);
}
if (checkbox_choic es < 5 )
{
alert("Please select 5 counties. \n" + checkbox_choice s + " entered so far.")
return (false);
}
alert(" *** Thank you for your selection. ***");
return (true);
}
-->
</script>
<form method="get" action="http://www.mysite.com/myresults.asp" onsubmit="retur n checkbox_checke r()" name="checkbox_ form">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td width="20%" valign="top">
<input type="checkbox" value="Oxford" name="checkbox" >Anglesey<br>
<input type="checkbox" value="Liverpoo l" name="checkbox" >Avon<br>
<input type="checkbox" value="Bedfords hire" name="checkbox" >Bedfordshire<b r>
<input type="checkbox" value="Berkshir e" name="checkbox" >Berkshire<br >
<input type="checkbox" value="London" name="checkbox" >Borders<br>
<input type="checkbox" value="Buckingh amshire" name="checkbox" >Buckinghamshir e<br>
<input type="checkbox" value="Cambridg eshire" name="checkbox" >Cambridgeshire <br>
<input type="checkbox" value="Manchest er" name="checkbox" >Central<br>
<input type="checkbox" value="Cheshire " name="checkbox" >Cheshire<br>
<input type="checkbox" value="Clevelan d" name="checkbox" >Cleveland<br >
<input type="checkbox" value="Leeds" name="checkbox" >Clwyd<br>
</td>
</tr>
</table>
<p align="center">
<input type="submit" value="Compare Counties">
</form>
----------SCRIPT END-----------
Comment