i need to add input to a select option when it is selected. whenever the user selects \'other\' an input box is there for the user to enter in data.
html:
You can use jquery .change() to bind change event of an element.
Try this one:
HTML
Jquery
$('select').change(function(){
if($('select option:selected').text() == "Other"){
$('label').show();
}
else{
$('label').hide();
}
});
Try in Fiddle
Updated:
You can also add an input-box dynamically -
HTML
Jquery
$('select').change(function(){
if($('select option:selected').text() == "Other"){
$('html select').after("");
}
else{
$('label').remove();
}
});
Try in Fiddle