Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with empty checkbox value

Status
Not open for further replies.

idam

Programmer
Nov 1, 2001
5
GB
Hi,

I want to pass checkbox values from one ASP page to another. The values are in an array.

Though I want to use If Then Else so that if the user has checked the check box, the value is displayed and if it has not been checked, another word (like 'No') is displayed

I am able to display the value of the checkbox if it has been checked, but I am having probs with it not being checked.

My code is below. I call in the values from the previous ASP page and split them. But then when a person hasn't ticked a box, the else statement never happens!

Massages = Request.form("Massage")
Massages = Split(Massages, ",")
For Each Massage in Massages
if Massage="Massage" then %>
<b>Yes</b>
<% else %>
<b>No</b>
<% end if
Next %>

Can anyone please shed some light on this please?
 
Unchecked checkboxes do not get submitted. If the receiving page knows how many checkboxes there should be then you could work it out by process of elimination.


Tony
reddot.gif WIDTH=500 HEIGHT=2 VSPACE=3

 
Thanks Tony. That places the problem into perspective for me now :)
 
Idam i assume that you have some rows that can have or not Massages.If those rows has some ID's(for example database id's or some identification) you can do another trick.
As for your example you should knw that if you use same names for an form field then you wont need to use Split(...) cuz data it's already in an collection.
Code:
Massages = Request.form("Massage") 
For Each Massage in Massages 
if Massage="Massage" then %> 
<b>Yes</b>
<% else %>
<b>No</b>
<% end if 
Next
%>

I would recomand using

Massages = Request.form("Massage") 
for i=0 to Massages.Count-1
if Massages(i)="Massage" then %> 
<b>Yes</b>
<% else %>
<b>No</b>
<% end if 
next
%>

________
George, M
Searches(faq333-4906),Carts(faq333-4911)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top