 |
| ASP Forms As of Oct 5, 2005, this forum is now locked. Please use "Classic ASP beginner" at http://p2p.wrox.com/forum.asp?FORUM_ID=54 or "Classic ASP Professional" http://p2p.wrox.com/forum.asp?FORUM_ID=56 instead. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP Forms 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
|
|
|
|

November 9th, 2004, 04:35 PM
|
|
Authorized User
|
|
Join Date: Sep 2004
Posts: 68
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
Checkboxes and count parameter
Good afternoon all.
I'm working on a form that will have lots of checkboxes: a checkbox for each record written from my database.
I plan to process each text box individually once the form is submitted; I will process each checkbox via indexing, i.e.:
request.form("chkLiveYN") (strCounterField).
However, I have a problem. It seems my processing ignores the indexing for the checkbox.
================================================== ================
My form uses a checkbox and a hidden field as show below:
Response.Write "<tr bgcolor=" & strRowColor & ">"
Response.Write "<td><a href=updateWebsites.asp?ID=" & adoRs ("websiteMasterID").value & "&name=" & strFixName & " class=blueLink12>" & adoRs ("description") & "</a></td>"
response.write "<td><INPUT type=checkbox name=chkLiveYN value=live ></td>"
response.write "<td><INPUT type=checkbox name=chkDelete value=delete ></td>"
response.write "<INPUT type=hidden name=txtWebsiteMasterID value=" & adoRs ("websiteMasterID").value & " >"
Response.Write "</tr>"
================================================== =================
Once I submit the form, I use the following code to determine the index value (how many checkboxes have been written to the screen:
response.write Request.Form("txtWebsiteMasterID").count
response.write Request.Form("chkLiveYN").count
the first line (for txtWebsiteMasterID) returns the correct value (which is 3, since there are 3 records written to the screen) however the second line (for chkLiveYN) returns a value of 0.
I know this is simple and I'm making a simple mistake. What is it?
thank you for your help!!!
Sal
|
|

November 9th, 2004, 09:12 PM
|
|
Friend of Wrox
|
|
Join Date: Sep 2003
Posts: 363
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Hello,
No need to check for count. When you assign the same name to all checkboxes and submit the form, just use
request.form("checkboxname")
It retrieve the values of checkboxes which you have checked.
Ex: 1, 3, 4, 6
---------
Rajani
|
|

November 10th, 2004, 08:41 AM
|
|
Authorized User
|
|
Join Date: Sep 2004
Posts: 68
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
Rajani,
thanks for getting back to me on this however, the suggestion mentioned below still does not work. i think i'm doing something wrong in my code:
response.write Request.Form("txtWebsiteMasterID")
response.write Request.Form("chkLiveYN")
the line, response.write Request.Form("txtWebsiteMasterID")returns values as you anticipated however, the second line, response.write Request.Form("chkLiveYN") returns no values. I'm doing something wrong but can't determine what it is.
thanks for your help.
sal
|
|

November 10th, 2004, 12:04 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Are you sure you checked that checkbox of which you are expecting the value from? If not checked it wont return anything.
Also it is better you wrap them within single quotes as shown below.
<input type='checkbox' name='chkLiveYN' value='live'...
Cheers!
_________________________
- Vijay G
Strive for Perfection
|
|

November 10th, 2004, 01:02 PM
|
|
Authorized User
|
|
Join Date: Sep 2004
Posts: 68
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
Vijay,
Thanks for your response. Yes, I just found out that if the box is not checked, it's as if it doesn't exist. urggh! I need to look at all checkboxes written to my form: if the user checks it or unchecks it. any ideas?
thank you.
sal
|
|

November 12th, 2004, 11:24 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Use Request.FORM("checkboxname") after submission and see if that contains any value
May be something like this.
if len(Request.FORM("checkboxname"))>0 then
Response.write "It is checked"
ELSE
Response.write "It is UNCHECKED:"
End If
You may also validate that at the clientside using JAVASCRIPT.
Hope that helps.
Cheers!
_________________________
- Vijay G
Strive for Perfection
|
|
 |