javascript - Two options on onchange -


I have a drop down which is not a simple yes /

When the user "yes" Selects "page brings a new drop down (new product) to choose for them, when the user chooses" No ", then it should display separate drop down (non-sales reason)

On my webpage, when the user chooses "yes" it works, but nothing happens when they choose "no"

The change script is on:

   colspan = "2" style = "text-line: left; "& Gt; choose name;" Maintained "id =" maintained "onchange =" display (this, 'yes', 'no'); "I've put a code in jsfiddle  

It does not display correctly here for some reason (Nothing is hidden, but drop down

thanks

display function: this , 'yes' and ' not '. The third did not give a name in the function definition Has been done, and it has been effectively ignored; basically, every time you go When calling the function, the id1 parameter is passed as 'yes' .

Trying to regain But this is probably not doing what you want. txt will be inside the function always whatever is current (i.e. new) value, but it Always id1 ; and equally you will modify the document element only with the id element 'yes' .

fix it You can change the second argument in the onchange call for the new selected value but it is also not necessarily more important, as mentioned above, it can only determine the element from context. is. Instead, I will remove both the 'yes' and the 'no' parameter, and reduce my display () function, code> texts Now you know what it is, you can tell that the user has not chosen yes or no, and with a simple one - whatever you want to do in these separate cases, do it You can.


Comments