I am working in view File of opencart. I have 2 text boxes which set date and time respectively. I have a checkbox, its value is 1 when checked and 0 when not checked.What i want is that date and time fields should be hidden if above check box is checked (Done till now).If checkbox is unchecked, show these fields as they are now(Done till now). Current code.
HTML
<tr id="row_ship_date">
<td>
Shipment Date:
</td>
<td>
<input type="text" id="ship_date" name="ship_date" class="date" onchange="getServices();" />
</td>
</tr>
<tr id="row_ship_time">
<td>
Shipment Time:
</td>
<td>
<input type="text" id="ship_time" name="ship_time" class="time" />
</td>
</tr>
<?php
if (isset($current_date_shipment) && $current_date_shipment == 1) // check box value check{?>
<script type="text/javascript">
document.getElementById('row_ship_date').style.display='none';
document.getElementById('row_ship_time').style.display='none';
getServices();
<?php }
?>
JS:
function getServices() {
alert('test');
var ship_date = $('#ship_date').val();
var ship_time = $('#ship_time').val();
// code so on..
}
Current issues
1) Iam unable to call getservices() function if checkbox check is true (php check of if statement) because if its false it gets call onchange event of date and works fine.
2) how can i set current date and current time respectively for both text fields if this function is called under if statement (when both fields are hidden), some thing like
function getServices() {
alert('test');
var ship_date = new Date();
var ship_time = currentTime();
// code so on..
}
Aucun commentaire:
Enregistrer un commentaire