 |
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
|
|
|

October 18th, 2006, 07:14 AM
|
Authorized User
|
|
Join Date: Oct 2006
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

October 18th, 2006, 07:25 AM
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
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
|

October 18th, 2006, 07:29 AM
|
Authorized User
|
|
Join Date: Oct 2006
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

October 18th, 2006, 07:32 AM
|
Authorized User
|
|
Join Date: Oct 2006
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
BTW, your code is generating the following error
Error 500
Internal Server Error
-----------------------------------------------
www.chargertek.in - Cheapest WebHosting
|

October 19th, 2006, 12:39 AM
|
Authorized User
|
|
Join Date: Oct 2006
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Ok i figured out the problem
But now I want each value in seperate variable, how can I?
Thanx
-----------------------------------------------
www.chargertek.in - Cheapest WebHosting
|

October 19th, 2006, 06:37 AM
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
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
|

November 21st, 2006, 01:00 AM
|
Registered User
|
|
Join Date: Aug 2006
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|
 |