Sample HTML Code
<p><select name="status" class="form-control" id="showThisItem">
<option value="">
Select Status
</option>
<option value="Paid">
Paid
</option>
<option value="Unpaid">
Unpaid
</option>
</select></p>
<td id="showHide">
<label>Due Date</label>
<input type="text" name="due_date" class="form-control" data-date-format="mm/dd/yy" id="datepicker" required="true">
</td>
JavaScript Function for jQuery
$('#showHide').hide(500);
var showThis = $('#showThisItem');
var select = this.value;
showThis.change(function () {
if ($(this).val() == 'Unpaid') {
$('#showHide').show(500);
}
else {
$('#showHide').hide(500);
}
});
The code above is used to toggle the visibility of a td
element. When "Paid" is selected, the td
is hidden, and when "Unpaid" is selected, the td
is displayed. It starts off hidden initially on page load.
However, there seems to be an issue where submitting the form works when "Unpaid" is selected, but not when "Paid" is selected.