I am using the following coding in a website I am building but rather than the text input field showing if one option is selected, I need it show if the user selects other options as well?
for example oit currently shows the text input field if the user selects option 2 from the select menu but need to show as well if the user selects option 4 in the select menu, below is my jfiddle code so far
it currently shows the extra text input fields when Domestic+ is selected in the select menu but need the text input fields to show as well when Commercial is selected within the dropdown menu
I found something similar on stackoverflow, see link below
<http://stackoverflow.com/questions/21007591/using-jquery-to-hide-form-elements-based-on-selected-dropdown-option/33055467#33055467>
<http://jsfiddle.net/gxxkdz2m/2/>
Thank you in advance
Ian
Is this what you mean? I added comments explaining the code where I changed it.
$(document).ready(function () {
$('#support select[name="support_plans"]').change(function () {
// get selected plan value
var plan = $('#support select[name="support_plans"] option:selected').val();
// check whether 'Domestic+' or 'Commercial+' is selected
if (plan == 'Domestic+' || plan =='Commercial+') {
$('#extra').show();
} else {
$('#extra').hide();
}
});
});
Fiddle of my Version (updated your fiddle).
use this javascript code:
$(document).ready(function () {
$('#support select[name="support_plans"]').change(function () {
if ($('#support select[name="support_plans"] option:selected').val() == 'Domestic+') {
$('#extra').css('display', 'inline');
} else {
$('#extra').css('display', 'none');
}
});
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.