473,407 Members | 2,546 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Simple check box solution?

36
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?county1=London&county2=Oxford&county 3=Leeds&county4=Manchester&county5=Liverpool"

INSTEAD OF

"www.mysite.com/myresults.asp?checkbox=London&checkbox=Oxford&chec kbox=Leeds&checkbox=Manchester&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="JavaScript">
<!--
function checkbox_checker()
{

var checkbox_choices = 0;

for (counter = 0; counter < checkbox_form.checkbox.length; counter++)
{

if (checkbox_form.checkbox[counter].checked)
{ checkbox_choices = checkbox_choices + 1; }

}

if (checkbox_choices > 5 )
{

msg="You're limited to only three selections.\n"
msg=msg + "You have made " + checkbox_choices + " selections.\n"
msg=msg + "Please remove " + (checkbox_choices-5) + " selection(s)."
alert(msg)
return (false);
}

if (checkbox_choices < 5 )
{

alert("Please select 5 counties. \n" + checkbox_choices + " 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="return checkbox_checker()" 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="Liverpool" name="checkbox">Avon<br>
<input type="checkbox" value="Bedfordshire" name="checkbox">Bedfordshire<br>
<input type="checkbox" value="Berkshire" name="checkbox">Berkshire<br>
<input type="checkbox" value="London" name="checkbox">Borders<br>
<input type="checkbox" value="Buckinghamshire" name="checkbox">Buckinghamshire<br>
<input type="checkbox" value="Cambridgeshire" name="checkbox">Cambridgeshire<br>
<input type="checkbox" value="Manchester" name="checkbox">Central<br>
<input type="checkbox" value="Cheshire" name="checkbox">Cheshire<br>
<input type="checkbox" value="Cleveland" 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-----------
Nov 7 '07 #1
1 1538
iam_clint
1,208 Expert 1GB
you can use

document.getElementsByTagName("input");

then run through all of them and check for
.getAttribute("type")=="checkbox"

then change the name of each checkbox to the corresponding name for the form.
Nov 8 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: PCL | last post by:
I am trying to get the value from a simple stored procedure - the Stored Procedure returns 1 record with one field - it is basically "Select Max(po) as MaxPo from PODB" I want to store that...
2
by: MENTAT | last post by:
Hi, I am trying to create an installer for my web application. So I added a web setup project to my solution (I am using VS.NET 2003). Been playing around with it since then and it basically...
8
by: Mark | last post by:
Hi, I'm looking for some ideas on how to build a very simple Event processing framework in my C++ app. Here is a quick background ... I'm building a multithreaded app in C++ (on Linux) that...
6
by: Sergio | last post by:
for my web site I am looking for a simple PHP plain text menu system, the menu would have at least four levels and about 200 links, at starting only the main levels should appear, for example : ...
51
by: Alan | last post by:
hi all, I want to define a constant length string, say 4 then in a function at some time, I want to set the string to a constant value, say a below is my code but it fails what is the correct...
2
by: sbu_c_student | last post by:
Hello.... I wanted to know if there was a way to write simple c code using visual .net? I really want to get used to the ide but i'm not sure how to.. Any comments will be appreciated... ...
18
by: Q. John Chen | last post by:
I have Vidation Controls First One: Simple exluce certain special characters: say no a or b or c in the string: * Second One: I required date be entered in "MM/DD/YYYY" format: //+4 How...
12
by: Peter Proost | last post by:
Hi group, I've got what seems a simple problem, but I can't find the solution. I've got a textbox and a handheld scanner to scan barcodes, the scanner just generates keypresses like a keyboard...
0
by: Rich | last post by:
(1) Is there a better place to pose the question below? (2) I am starting to convert my enterprise solution from VS 2003 (.NET v1.1.4322) to VS 2005 Professional (.NET v2.0.50727). The entire...
27
by: one man army | last post by:
Hi All- I am new to PHP. I found FAQTS and the php manual. I am trying this sequence, but getting 'no zip string found:'... PHP Version 4.4.0 $doc = new DomDocument; $res =...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.