I have this piece of code that, whan a user selects Other from the drop down a div containing a textbox will appear for the user to type in what "other" is. Currently, selecting "other" works fine, and then selecting another value after selecting "other" also works fine.
Code: Select all
function domainchek() {
var domaincomp = document.getElementById('domaincompany');
var domaintd = document.getElementById('domaintd');
if (domaincomp.value == 'other') {
domaintd.innerHTML+="<div id='domaindivvy' style='margin:0px;padding:0px;'><input type='text' name='domaincompany2' size='22'/></div>";
}
else {
domaintd.removeChild(domaindivvy);
}
}
Code: Select all
domaintd.removeChild(domaindivvy);
Code: Select all
domaintd.innerHTML="<select><option>etc... without the 'domaindivvy' div";
If you dont understand what I'm trying to say, this is whats supposed to happen:
User selects a value
If the value is "other" then dispay the textbox
If the value is not other, don't display the textbox
As a user has the option to then change the value:
If the previous value was "other" then clear the textbox
If the previous value was not "other" then dont clear the textbox
Thanks.