html - Form with drop-down lists -


i have html form in script drop-down lists. example:

<select name="1"> <option value="a">a</option> <option value="b">b</option> <option value="c">c</option> </select>   <select name="2"> <option value="a">a</option> <option value="b">b</option> <option value="c">c</option> </select> 

as can see, options in both lists identical. should do, stop user selecting same option? example, if user selects option "b" list "1", , tries select option "b" list "2", want selected option list "1" disappear, user can't submit same values...

sorry english. hope made myself clear...

you can validate form this.

tested working code:

    <html> <head>  <script> //put javascript function in header. validates 1 click submit button function validateform() {     var x = document.forms["myform"]["box1"].value;//this selection of dropdown box 1     var y = document.forms["myform"]["box2"].value;//this selection of dropdown box 2     if (x == y) {//use if statement check if selection same          alert("selection cannot same");//error message         eturn false;     } } </script>  </head>  <body>  <form name="myform" action="" onsubmit="return validateform()" method=""> <!--onsubmit calls function once submit button clicked-->  <select name="box1"> <option value="a">a</option> <option value="b">b</option> <option value="c">c</option> </select>  <select name="box2"> <option value="a">a</option> <option value="b">b</option> <option value="c">c</option> </select>  <input type="submit" value="submit"> </form>  </body> </html> 

Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -