Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old May 27th, 2006, 05:07 PM
Authorized User
 
Join Date: Mar 2005
Location: arima, West Indies, Trinidad and Tobago.
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to arimakidd
Default Passing Multiple Checkbox Values

How do I check for multiple 'checked' checkbox values? For instance, I have a form with 5 checkbox options. Suppose the user only checked 3. How do I check how many boxes were chekcked and then of course get the value of each check box?

  #2 (permalink)  
Old May 28th, 2006, 03:05 AM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

;;;How do I check how many boxes were checked and then of course get the value of each check box?
Do you need the number of checked boxes in addition to each of thier values?
Do you need to ensure a certain number of boxes are checked before the form can be posted?

Getting the values is the same as any other form elements, using:
request.form("chqBoxName")
on the page the form is being posted to.

Two common ways:
1..Name all the checkboxes the same. The value(s) of each checkbox(s) that have been checked get posted as one commer delimited string.

2..Name them uniquely. Address each named checkboxes seperatley as required.

Wind is your friend
Matt
  #3 (permalink)  
Old May 28th, 2006, 08:20 AM
Authorized User
 
Join Date: Jun 2003
Location: Richmond, VA, USA.
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to erobb Send a message via Yahoo to erobb
Default

<form name="form1" method="post" action="page.asp">
    <input type="checkbox" name="checkbox" value="1">
    <input type="checkbox" name="checkbox" value="2">
    <input type="checkbox" name="checkbox" value="3">
</form>

--Page.asp--
chkCnt=request.form("checkbox").count
response.write "Number of boxes checked: "&chkCnt&"<BR>"
i=1
if chkCnt > 0 then
  do while i <=chkCnt
    response.write request.form("checkbox")(i) & "check value<BR>"
  i=i+1
  loop
end if

Earl
www.jhdesigninc.com
  #4 (permalink)  
Old May 28th, 2006, 10:44 AM
Authorized User
 
Join Date: Mar 2005
Location: arima, West Indies, Trinidad and Tobago.
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to arimakidd
Default

Excellent. Great!. This works. Thanks.

  #5 (permalink)  
Old October 19th, 2007, 10:25 AM
Registered User
 
Join Date: Oct 2007
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I know this is an older post, however, I am looking to do something very simular, but how can I pass multiple values like the exammple below to another .asp page to do the work?

imryn
  #6 (permalink)  
Old October 19th, 2007, 10:28 AM
Registered User
 
Join Date: Oct 2007
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I know this is an older post, however, I am looking to do something very simular, but how can I pass multiple values like the example below to another .asp page to do the work?

imryn


Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing multiple values to JSp suhasdoke Servlets 1 April 16th, 2007 11:31 PM
insert multiple checkbox values in to database muthumari_p2003@yahoo.com Pro JSP 0 March 29th, 2006 08:23 AM
passing values from multiple list box tulincim Javascript 4 September 14th, 2005 02:02 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.