I have a select box with a list of countries - if the select value is changed to certain countries I want a VAT box to display otherwise is should remain hidden.
When page loads and country-display is blank then vat-display should be hidden - if country-display is changed to Ireland or Spain (or is already set to Ireland or Spain) then vat-display should show. If country-display is changed to United States, it should hide vat-display and so on.
I have checked out so many other answers which look similar but cannot get this to work - I thought https://stackoverflow.com/a/11295625/1278201 was what I was looking for but it still does not work even though the linked fiddle in that answer seems to do exactly what I need.
<script type="text/javascript" src="includes/js/jquery-1.7.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#country-display").on("change", function() {
$("#vat-display").hide();
if ( $(this).val() == 'Ireland'||$(this).val() == 'Spain' ) {
$("#vat-display").show();
}
});
});
</script>
<div id="country-display">
<label>Country:</label>
<select name="country">
<option value="">Please choose</option>
<option value="United States">United States</option>
<option value="United Kingdom">United Kingdom</option>
<option value="Ireland">Ireland</option>
<option value="Spain">Spain</option>
</select>
</div>
<div id="vat-display" style="display:none;">
<label>VAT:</label>
<input type="text" name="vat">
</div>