good evening,
I am trying to allow my users to enter in text if they don't find their option on my drop down menu. In the code below, I can get a text box to show up when I select 'Other' on the drop down menu. However, I cannot get it to work when I try to select 'Other' on the second drop down menu. Any ideas about how I can start getting the second drop down menu to show a text box just like the first one does?
Also, how do I get the text box to appear on the same line the dropdown menu was? By using this code, my formatting is kind of unprofessional.
Thank you for any insight......Je rry
I am trying to allow my users to enter in text if they don't find their option on my drop down menu. In the code below, I can get a text box to show up when I select 'Other' on the drop down menu. However, I cannot get it to work when I try to select 'Other' on the second drop down menu. Any ideas about how I can start getting the second drop down menu to show a text box just like the first one does?
Also, how do I get the text box to appear on the same line the dropdown menu was? By using this code, my formatting is kind of unprofessional.
Thank you for any insight......Je rry
Code:
<p>Company: <select name="company" id="mySelect" onChange="swap();" style=display:inline;">
<option selected="x"></option>
<option value="y">y</option>
<option value="z">z</option>
<option value="Other">Other..</option>
</select>
<input type="text" name="company" id="myText" style="display:none;" onclick="swapback()"></p>
<script type="text/javascript">
function swap() {
if(document.getElementById('mySelect').value == 'Other'){
document.getElementById('mySelect').style.display = 'none';
document.getElementById('myText').style.display = 'block';
document.getElementById('myText').focus();
}
}
function swapback() {
document.getElementById('mySelect').selectedIndex = 0;
document.getElementById('mySelect').style.display = 'block';
document.getElementById('myText').style.display = 'none';
}
</script>
<p>Company: <select name="company" id="mySelect" onChange="swap();" style=display:inline;">
<option selected="x"></option>
<option value="y">y</option>
<option value="z">z</option>
<option value="Other">Other..</option>
</select>
<input type="text" name="company" id="myText" style="display:none;" onclick="swapback()"></p>
<script type="text/javascript">
function swap() {
if(document.getElementById('mySelect').value == 'Other'){
document.getElementById('mySelect').style.display = 'none';
document.getElementById('myText').style.display = 'block';
document.getElementById('myText').focus();
}
}
function swapback() {
document.getElementById('mySelect').selectedIndex = 0;
document.getElementById('mySelect').style.display = 'block';
document.getElementById('myText').style.display = 'none';
}
</script>
Comment