How to call JS function with in HTML
<p>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:</p>

<p>HTML</p>

<pre><code>&lt;tr id="row_ship_date"&gt;
    &lt;td&gt;
        Shipment Date:
    &lt;/td&gt;
    &lt;td&gt;
        &lt;input type="text" id="ship_date" name="ship_date" class="date" onchange="getServices();" /&gt;
    &lt;/td&gt;
&lt;/tr&gt;
&lt;tr id="row_ship_time"&gt;
    &lt;td&gt;
        Shipment Time:
    &lt;/td&gt;
    &lt;td&gt;
        &lt;input type="text" id="ship_time" name="ship_time" class="time" /&gt;
    &lt;/td&gt;
&lt;/tr&gt; 

&lt;?php   
    if (isset($current_date_shipment) &amp;&amp; $current_date_shipment == 1) // check box value check{?&gt;
        &lt;script type="text/javascript"&gt;
            document.getElementById('row_ship_date').style.display='none';
            document.getElementById('row_ship_time').style.display='none';
            getServices();
        &lt;/script&gt;
    &lt;?php }
?&gt;
</code></pre>

<p>JS:</p>

<pre><code>function getServices()      {
    alert('test');
    var ship_date = $('#ship_date').val();
    var ship_time = $('#ship_time').val();
    // code so on..
}
</code></pre>

<p><strong>Current issues</strong></p>

<p>1) I am unable to call <code>getServices()</code> if checkbox check is true (php check of <code>if</code> statement) because if its false it gets call onchange event of date and works fine.</p>

<p>2) how can I set current date and current time respectively for both text fields if this function is called under <code>if</code> statement (when both fields are hidden), something like: </p>

<pre><code>function getServices()      {
    alert('test');
    var ship_date = new Date();
    var ship_time = currentTime();
    // code so on..
}
</code></pre>