I am trying to do something in terms of making a text box appear and dissapear depending on the selection of a drop down list box.
I have the following code:-
</select> <input type="text" name="txt_asoslink"/>
Now when a user selects “Yes” from the drop down i want the text box to appear. Otherwise i dont want it to be visible…
How can i do this?
I wrote this code for you quickly and tested it in IE and SeaMonkey. Not only will it display your text input when ‘Yes’ is selected it will also hide it again if ‘No’ or ‘Choose…’ are re-selected.
Select = document.getElementById('ASOS');
Input = document.getElementById('input');
if (Select.value == 'Yes')
Input.innerHTML = '<input type="text" name="txt_asoslink" value="">';
Input.innerHTML = '';
<select name="ASOS" id="ASOS" onchange="change_input();">
Note that when you submit the form the text box value WILL also be submitted to your script with everything else despite it not being visible in the main source code.
You’re welcome, glad I could help