Hide/Show Fields on Selected Drop Down Value
Posted: 2020-11-08 16:02
When adding record to table_c and selecting "multi" from drop down list I want to show labels #range1, #range2, #single, #associated.
The default value for the drop down box #type is "single" which hides the above labels #range1 etc., the code for this works but nothing when "multi" is selected.
Please advice.
The default value for the drop down box #type is "single" which hides the above labels #range1 etc., the code for this works but nothing when "multi" is selected.
Code: Select all
/* hide unhide fields */
if (!$j("#type").val() != "multi") {
$j("#range1").parents('.form-group').hide();
$j("#range2").parents('.form-group').hide();
$j("#single").parents('.form-group').hide();
$j("#associated").parents('.form-group').hide();
// alert($j('#type').val());
// alert("1st if statement detected != multi");
}
$j("#type").on('selected', function() {
if (!$j("#type").val() == "multi") {
$j("label[for='range1']").parents('.form-group').show();
$j("label[for='range2']").parents('.form-group').show();
$j("#single").parents('.form-group').show();
$j("#associated").parents('.form-group').show();
// alert("**** type.val equals multi ****");
alert($j('type').val());
}
else {
$j("label[for='range1']").parents('.form-group').hide();
$j("label[for='range2']").parents('.form-group').hide();
$j("#single").parents('.form-group').hide();
$j("#associated").parents('.form-group').hide();
alert("type.val not equals **multi**");
// alert($j('#type').val());
}
});