Faster way to check dropdown group.

Discussion in 'ASP General' started by MN, Dec 23, 2004.

  1. MN

    MN Guest

    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, Dec 23, 2004
    #1
    1. Advertising

  2. 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" <> wrote in message
    news:...
    > 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], Dec 23, 2004
    #2
    1. Advertising

  3. MN

    MN Guest

    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" <> wrote in message
    > news:...
    > > 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, Dec 23, 2004
    #3
  4. 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.
    Bob Barrows [MVP], Dec 23, 2004
    #4
  5. Yes, I'd definitely go with the radio buttons.

    Ray at work

    "MN" <> wrote in message
    news:D...
    > 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?
    >
    Ray Costanzo [MVP], Dec 23, 2004
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. vishnu
    Replies:
    1
    Views:
    1,187
    Patrick.O.Ige
    Mar 25, 2006
  2. Mike
    Replies:
    1
    Views:
    793
  3. acadam
    Replies:
    0
    Views:
    746
    acadam
    Dec 27, 2006
  4. Replies:
    2
    Views:
    430
  5. Steve Myers
    Replies:
    2
    Views:
    264
    Steve Myers
    Nov 20, 2003
Loading...

Share This Page