IIS ASP - Faster way to check dropdown group.

This is Interesting: Free IT Magazines  
Home > Archive > IIS ASP > December 2004 > Faster way to check dropdown group.





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Faster way to check dropdown group.
MN

2004-12-23, 5:59 pm

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
Ray Costanzo [MVP]

2004-12-23, 5:59 pm

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

"MN" <MN@discussions.microsoft.com> wrote in message
news:6A73D2D9-1DE6-476D-B8F2-4378FA3FE8D2@microsoft.com...
> 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



MN

2004-12-23, 5:59 pm

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

"Ray Costanzo [MVP]" wrote:

> 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
>
> "MN" <MN@discussions.microsoft.com> wrote in message
> news:6A73D2D9-1DE6-476D-B8F2-4378FA3FE8D2@microsoft.com...
> issue.
> selected
>
>
>

Bob Barrows [MVP]

2004-12-23, 5:59 pm

MN wrote:
> 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
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


Ray Costanzo [MVP]

2004-12-23, 5:59 pm

Yes, I'd definitely go with the radio buttons.

Ray at work

"MN" <MN@discussions.microsoft.com> wrote in message
news:DA5E086F-EA39-4C62-92E6-442727898A13@microsoft.com...
> 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?
>



Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com