Hi Sir/Ma’am,
Good day!
I made a checkbox and I use jquery on displaying one textbox if the user check the Yes checkbox but if the user check the no the textbox will be hide. It works fine now but when the checkbox has vale from the database and which is no the textbox was displayed so that I made a if condition that only if the checkbox is Yes or ” but I noticed that when I check the Yes the textbox was not display because from the database the value of textbox is No.
[CODE]
$(document).ready(function() {
$(“.ticket”).change(function () {
//check if its checked. If checked move inside and check for others value
if (this.checked && this.value === “Yes”) {
//add a text box next to it
$(“#destination_data”).show();
}
else if (this.checked && this.value === “No”) {
//remove if unchecked
$(“#destination_data”).hide();
}
});
});
if($ticket == ”)
{
?>
#destination_data {display: none; display:}
<?php
}
?>
<tr>
<td class=”row_leaveform”>Travel Tickets:</td>
<td class=”row_leavedata”>
<input type=”checkbox” class=”ticket” name=”ticket” value=”Yes” <?php if($ticket==”Yes”) echo ‘checked=”checked”‘; ?>>Yes
<input type=”checkbox” class=”ticket” name=”ticket” value=”No” <?php if($ticket==”No”) echo ‘checked=”checked”‘; ?>>No
</td>
</tr>
<tr id=”destination_data”>
<?php
if($ticket==”Yes” || $ticket==”)
{
?>
<td class=”row_leaveform”>Destination </td>
<td class=”row_leavedata”><b>Doha</b> to <input type=”text” name=”destination” id=”destination” value=”<?php echo $nationality; ?>” size=”31″></td>
<?php
}
?>
</tr>
it works fine when $ticket == ”;
but when in terms of update and the $ticket has value of No
in this code the destination was not display but when I try to check the Yes the destination was not display. I want it to display once I click the Yes if need to update my data.
if my remove the if condition even the value of ticket is No the destination was display ?
I want to happen is if
$ticket == ” or $ticket == ‘Yes’ the destination display
$ticket == ‘No’ destination not display but when I click the Yes the destination should be display
Thank you.