I currently have a situation that really may not be a big deal, but I've tried looking everywhere and haven't really found the answer to my problem.
Well, we all know that the tag <select>
is used to create a list of <option>
, I am working in JavaScript with a code based on HTML, since I am making a page with dynamic elements that do not need to reload the page to fulfill their function, for that reason I do not want put PHP into the code, since PHP needs the page to be reloaded for its functions, the problem is that I have no idea what to do after defining the possible options of the select.
<select id="opcion" required>
<option value="1">boton 1</option>
<option value="2">boton 2</option>
</select>
What I would like to do is that when the first option is selected it shows a button and then if I press the second option, it hides the first button and creates a new one.
The buttons I do know how to configure them, really this question is simple and short, but I can't find anywhere how to apply the conditions of the select, I tried with a IF
, but nothing happened.
This question had already been answered in at least one question in English: Jquery enable/disable button based on select option
An example is included with that answer: http://jsfiddle.net/mblase75/vZacx/
In your case, if you want to hide the buttons, you can use show/hide: