This is my form:
<form name="ff">
<select id="type" name="type">
<option value="0">Federal</option>
<option value="1">Estadual</option>
<option value="2">Municipal</option>
</select><br>
<div id="state" >
<label>Estado</label>
<input type="text" name="state"/> <br>
</div>
<div id="city">
<label>Cidade</label>
<input type="text" name="city" /><br>
</div>
<label>Nome</label>
<input type="text" name="name" id="name" />
</form>
The jquery script:
$(document).ready(function() {
$('#state').hide();
$('#city').hide();
$('#type').change(function() {
if ($('#type').val() == 1) {
$('#state').show();
$('#city').hide();
}if($('#type').val() == 2) {
$('#state').show();
$('#city').show();
}if($('#type').val() == 0) {
$('#state').hide();
$('#city').hide();
}
});
});
Example: link
But when I edit it is not working correctly When I select type the second option the city does not disable
Problem example: link
It's getting this way
andshouldbelikethis