Below is a standard two select drop down form menu’s
<select name="ServicePropertySize">
<option value="">—Please choose an option—</option>
<option value="Up To 4000 sq ft">Up To 4000 sq ft</option>
<option value="4000 -> 4500 sq ft">4000 -> 4500 sq ft</option>
<option value="4500 -> 5000 sq ft">4500 -> 5000 sq ft</option>
</select>
<select name="PackageMowingPricePointWithText">
<option value="">—Please choose an option—</option>
<option value="$30.00 - Up To 4000 sq ft">$30.00 - Up To 4000 sq ft</option>
<option value="$35.00 - 4000 -> 4500 sq ft">$35.00 - 4000 -> 4500 sq ft</option>
<option value="$40.00 - 4500 -> 5000 sq ft">$40.00 - 4500 -> 5000 sq ft</option>
<option value="$40.00 - 5000 -> 5500 sq ft">$40.00 - 5000 -> 5500 sq ft</option>
</select>
The code below will select the value in drop down #2 if the value selected "equals" the value selected in drop down #1.
I need the code below modified to select the option in drop down #2 where the value "contains" the value selected from drop down #1
$('select[name="ServicePropertySize"]').change(function() {
var PropertySizeSelected = $("option:selected", this).val();
$("select[name='PackageMowingPricePointWithText']").find("option").filter(function(index) {
return PropertySizeSelected === $(this).text();
}).prop("selected", "selected");
})
2
Answers
This one will select default value if not found