I am using a jQuery script with PHP to conditionally show/hide form fields based on dropdown selection.
The script is:
//Hide the field initially
$("#hide1").hide();
//Show the text field only when the third option is chosen - this doesn't
$('#project-type').change(function() {
if ($("#project-type").val() == "Value 1") {
$("#hide1").show();
}
else {
$("#hide1").hide();
}
});
I want to be able to add an array of values to the if ($("#project-type").val() == "Value 1") so if there are five values, I want a certain field to show when values 1 and 3 are selected but not the others. I have tried a few methods but they all result in all the values showing the hidden field.
Any help is appreciated.