Help with dropdownlist validation using javascript

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • scott

    Help with dropdownlist validation using javascript

    Hello,

    Thanks in advance for any help you might be able to offer...

    I have an html table with two columns and 10 rows. The first column
    contains a textbox that is populated. The second column contains a
    drop down box with selectable values from 1-9. This row is repeated
    10 times with different text in each rows first column but with the
    exact same drop downlist in all rows...to give you a table of 10
    elements long and 2 elements wide.

    This is where the fun begins...I want to limit the user to only be
    able to select the number from the drop down box once. If the user
    selected 1 in row 1 then that user cannot select 1 in any of the other
    9 rows and so on...am I making myself clear?

    I don't necessarily have to have the number disappear from the drop
    down list once it is used but it would be nice that if the user has
    already selected that value that I could give some kind of an error
    messge to them....

    I have no idea how to accomplish this...the application is written
    using asp.net 2.0 and all objects are generated dynamically when the
    page is displayed to the user. Due to application design I don't
    believe I can handle a postback event.

    I really appreciate any help with this matter.

    Thanks,
    Scott



  • SirCodesALot

    #2
    Re: Help with dropdownlist validation using javascript

    On Apr 28, 1:28 pm, scott <sdaniel1...@gm ail.comwrote:
    Hello,
    >
    Thanks in advance for any help you might be able to offer...
    >
    I have an html table with two columns and 10 rows.  The first column
    contains a textbox that is populated. The second column contains a
    drop down box with selectable values from 1-9.  This row is repeated
    10 times with  different text in each rows first column but with the
    exact same drop downlist in all rows...to give you a table of 10
    elements long and 2 elements wide.
    >
    This is where the fun begins...I want to limit the user to only be
    able to select the number from the drop down box once.  If the user
    selected 1 in row 1 then that user cannot select 1 in any of the other
    9 rows and so on...am I making myself clear?
    >
    I don't necessarily have to have the number disappear from the drop
    down list once it is used but it would be nice that if the user has
    already selected that value that I could give some kind of an error
    messge to them....
    >
    I have no idea how to accomplish this...the application is written
    using asp.net 2.0 and all objects are generated dynamically when the
    page is displayed to the user.  Due to application design I don't
    believe I can handle a postback event.
    >
    I really appreciate any help with this matter.
    >
    Thanks,
    Scott
    Hi Scott,

    Why cant you handle a post back event? So you are saying you cannot
    add an onselectedindex change event to the drop down lists? Seems like
    that since the page is creatd dynamically, then in the code behind
    would be a good place to filter the drop downs based on what has
    already been selected.

    You could add javascript to achieve the same. You would need to give
    each drop down a unique ID in the codehind then, add an onchange event
    to the drop downs to go look at what has been used and perform results
    accordingly.

    hope this helps.

    Comment

    Working...