hide and show button based on selection from the drop box
Hi,
I have the select drop box with Add and Remove value.
The default is all fields are showing up the page along with the submit button. What i need is when i select Remove from the requestType box, all fields are hidden and only Remove button shows on the page
My code didn't do what i want.
1. When i first go the page, the Remove button is hidden which is correct.
2. As soon as I select Add from the requestType field, the Remove button appears which is not correct.
3. When I select Remove again, the submit button is gone which is correct.
So, my question is why the Remove button show when i select Add, am i missing anything from the code? can you please help.
//show and hide with dropbox when select Add/Remove from the request type
$(document).ready(function(){
$('.ReType').show();
$('#requestType').change(function() {
$('.ReType').hide();
$('.' + $(this).val()).show();
});
});
//show remove button when remove option is selected from the request type
$(document).ready(function(){
$('.ReTypeRemove').hide();
$('#requestType').change(function() {
$('.ReTypeRemove').show();
$('.' + $(this).val()).show();
});
});
<table>
<tr>
<td>
<select id="requestType" name="requestType">
<option value="">Choose Request Type</option>
<option value="1">Add</option>
<option value="2">Remove</option>
</select>
</td>
<td class="ReType 1">
<select name="equipType" style="width: 18em;">
<option value="">Choose Equipment Type</option>
<option value="1">Company</option>
<option value="2">Personal</option>
</select>
</td>
<td class="ReType 1"> Start Date:<br> <cfinput type="datefield" name="startdate" id="startdate" value="" /></td>
<td class="ReType 1" >End Date:<br> <cfinput type="datefield" name="enddate" /></td>
</tr>
<tr>
<td class="ReType 1"> <cfinput type="submit" name="submit" value="Submit" class="button"></td>
<td class="ReTypeRemove 2"><cfinput type="submit" name="submit" value="Remove" class="button"></td>
</tr>
</table>