Faster way to check dropdown group.

M

MN

Hello all -

I have done ASP for a while but never found a quick way to handle this issue.

I have 8 dropdown boxes. Is there an easy to check that only 1 has selected
'Yes' and the others are 'No' without checking infinite combinations?

I usually do this with alot of coding for the combinations.

Any thoughts are appreciated.
MN
 
R

Ray Costanzo [MVP]

Are you talking about on generation of the dropdowns or when the form is
submitted? I'll assume you mean when the form is submitted.

Is the user only supposed to set 1 as yes, and all the other should then be
no? If so, how about using radio buttons instead...

What are you currently doing if a user submits the form with more than one
dropdown set to yes?

Ray at work
 
M

MN

Hi Ray,

Thanks for your response. Yes - I was referring to the latter when the form
is submitted. If more than one is selected as yes, I redirect my error
handler back to the user to indicate that only 1 can be selected as yes.
Might be more cumbersome than it's worth and switching to the option button
would be more beneficial.....yes?

Much thanks,
MN
 
B

Bob Barrows [MVP]

MN said:
Hello all -

I have done ASP for a while but never found a quick way to handle
this issue.

I have 8 dropdown boxes. Is there an easy to check that only 1 has
selected 'Yes' and the others are 'No' without checking infinite
combinations?

I usually do this with alot of coding for the combinations.

Any thoughts are appreciated.
MN

Dropdowns with only two choices? Why not radio buttons?

Assuming you've given them names to make them easily distinguishable from
the rest of the data elements in your form (say: dd1,...dd8), you can simply
loop through them. Something like this:

function OnlyOneYes()
dim i,curval, newval, bResult
curval="No"
bResult=true
for i=1 to 8
newval=request.form("dd" & i)
if newval = "Yes" then
if curVal = "Yes" then
bResult=false
exit for
else
curVal = newVal
end if
next
if curval = "Yes" then
OnlyOneYes=bResult
else
OnlyOneYes=false
end if
end function

Bob Barrows
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top