Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. 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 Databases 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
 
Old October 18th, 2006, 07:14 AM
Authorized User
 
Join Date: Oct 2006
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default Multi Checkbox selection - ASP

i have 5 checkboxes in one asp page, I am trying to get the values of all checkbox that are checked using for each loop but I dnt get any result, just a blank page. can u help me?


Herez my code where I am trying to get the values of all check boxes

Code:
for each cid in request.Form("chk")
response.Write cid & "<br>"
next
-----------------------------------------------
www.chargertek.in - Cheapest WebHosting
__________________
-----------------------------------------------
www.chargertek.in - Cheapest WebHosting
 
Old October 18th, 2006, 07:25 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

That is improper syntax. You are literally telling the interpeter:

For Each cid in the Form Collection variable chk

next

What you should be doing is:

For each item in Request.Form
Response.Write(Request.Form(item))
Next

-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.

^^Thats my signature
 
Old October 18th, 2006, 07:29 AM
Authorized User
 
Join Date: Oct 2006
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This is the code of my first page where the checkboxes are

Code:
<table>
<tr>
<td><input type="checkbox" name=chk[1] value=1></td>
</tr>

<tr>
<td><input type="checkbox" name=chk[2] value=2></td>
</tr>


<tr>
<td><input type="checkbox" name=chk[3] value=3></td>
</tr>

</table>
-----------------------------------------------
www.chargertek.in - Cheapest WebHosting
 
Old October 18th, 2006, 07:32 AM
Authorized User
 
Join Date: Oct 2006
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default

BTW, your code is generating the following error

Error 500

Internal Server Error

-----------------------------------------------
www.chargertek.in - Cheapest WebHosting
 
Old October 18th, 2006, 07:43 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

These sites will help you.

http://www.netzone.ch/caspdoc/Ch9_ASPBuiltIn40.html
http://www.elated.com/tutorials/programming/asp/forms/
http://www.aspwebpro.com/tutorials/a...ohandlevar.asp

-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.

^^Thats my signature
 
Old October 19th, 2006, 12:39 AM
Authorized User
 
Join Date: Oct 2006
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok i figured out the problem

But now I want each value in seperate variable, how can I?


Thanx

-----------------------------------------------
www.chargertek.in - Cheapest WebHosting
 
Old October 19th, 2006, 06:37 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Setting up logic to determine what item you are on in the Forms Collection is somewhat rudementary? I would use a SELECT CASE to determine which variable gets what value.

-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.

^^Thats my signature
 
Old November 21st, 2006, 01:00 AM
Registered User
 
Join Date: Aug 2006
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to albertindian2000
Default

hEY SIMPLE YA

Have the name of all checkboxes as same
Code:
<form method=post>
<input type="checkbox" name=check1 value="the first value">
<input type="checkbox" name=check1 value="the second value">
<input type="checkbox" name=check1 value="the third value">
<input type="checkbox" name=check1 value="the fourth value">
<input type="checkbox" name=check1 value="the fifth value">
<input type="checkbox" name=check1 value="the sizth value">
</form>

<%
if request.servervariables("REQUEST_METHOD")="POST" then

strData=request.form.item("check1")
strArr=split(strData,",")

for lIntI= 0 to ubound(strArr)
' Print each and every checked value
response.write strArr(lintI)
next

end IF
%>
Albert Arul Prakash
http://www.bepenfriends.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
multi checkbox problem deean Classic ASP XML 0 June 30th, 2008 12:43 AM
Disabling Selection Of CheckBox pady123 Pro Visual Basic 2005 1 April 8th, 2008 05:16 AM
checkbox selection in a webform vinodonline2000 ASP.NET 2.0 Basics 1 July 27th, 2007 05:52 AM
Multi selection dropdown control ninel ASP.NET 1.0 and 1.1 Basics 1 March 8th, 2007 12:56 PM
Excel Checkbox selection thru C# imsuneeta General .NET 1 June 16th, 2005 02:07 AM





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