need java script RRS feed

  • Question

  • User1205669949 posted

    I am having 3 drop down controls and all the three drop down are having same values , say 1,2,3,4. Now i want a java script which validates such that if i select 1 from 1st drop down control then on the remaining three i cannot select value 1. If i select , then the i need to pop up with validation error. 

    I am asking for java script because i need client side validation.

    Wednesday, September 29, 2010 8:41 PM


  • User-685154102 posted

    Why dont we try yourself? its easy.

    Suppose your dropdowns are

    <select name=select1>
    <option>Value 1</option>
    <option>Value 2</option>
    <option>Value 3</option>

    <select name=select2>
    <option>Value 1</option>
    <option>Value 2</option>
    <option>Value 3</option>

    <select name=select3>
    <option>Value 1</option>
    <option>Value 2</option>
    <option>Value 3</option>

    put onchnage() event on every dropdown. <select name=select1 onchange='OnChange(this.form.select1,this.form.select2,this.form.select3);'>

    <select name=select2 onchange='OnChange(this.form.select2,this.form.select1,this.form.select3);'>

    <select name=select3 onchange='OnChange(this.form.select3,this.form.select1,this.form.select2);'>

    Then here is the OnChange() method

    function OnChange(dropdown1,dropdown2,dropdown3)
        var myindex  = dropdown1.selectedIndex
        var SelValue1 = dropdown1.options[myindex].value
        myindex  = dropdown1.selectedIndex
        var SelValue2 = dropdown2.options[myindex].value

    myindex  = dropdown3.selectedIndex
        var SelValue3 = dropdown3.options[myindex].value

        //Now your custom code can go here to compare these values


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, September 29, 2010 9:58 PM