I have a contact form 7 select list
<label> Institute
[select* Institute id:if_cips_selection "Please choose..." "AAT" "CILT" "CIPD" "CIPS" "CMI" "ILM" "IoSCM"] </label>
<label> Level
[select* Level id:cips_level "Please choose..." "2" "3" "4" "5" "6" "7"] </label>
What I'd like to achieve is: if CIPS is selected in the Institute list then the level options would only be 2 & 3.
I have used a couple of different javascript snippets from existing questions as here but nothing works. The javascript I have tried works in a JSfiddle environment but does not work on my WP instance. code is here.
HTML
<select id="if_cips_selection">
<option value="AAT">AAT</option>
<option value="CIPS">CIPS</option>
<option value="CILT">CILT</option>
</select>
<select id="cips_level">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
Script
$(document).ready(function() {
$("#if_cips_selection").change(function() {
var val = $(this).val();
if (val == "CIPS") {
$("#cips_level").html("<option value='1'>2</option><option value='2'>3</option>");
}
});
});
Any advice would be great.