I tried to make an alert message after I click a checkbox. The alert message has a 2 seconds timeout. I tried to print start and end datetime with console.log to make sure it works perfectly and it shows the correct time, but it always needs extra time (10 seconds) to show the alert after end date when I click checkbox for the first time, and the alert message will running well (same as end date) after the first or start js.

And is it possible to disable the other checkbox when the alert message is still loading?

I don't know where my fault is and why this can happen? Do you have any idea?

This is my code:

<apex:inputCheckbox styleClass="checkOpex{!i.spd.ID} checkOpex {!i.spd.ID}" value="
   <apex:actionSupport event="onchange" action="{!updateOpex}" reRender=""> 
   <apex:param name="salesPlanIndex" value="{!i.index}" assignTo="{!salesPlanIndex}"/>


<script type="text/javascript">
    document.documentElement.style.setProperty('--screen-width', (screen.width - 120)+'px');
j$ = jQuery.noConflict();
    j$(document).ready(function() {
        j$(document).on('change', '.checkOpex', function(e) {
            var today = new Date();
            var date = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();
            console.log('Start Date'+ date);
            setTimeout(function () {
                    var today2 = new Date();
                    var end = today2.getHours() + ":" + today2.getMinutes() + ":" + today2.getSeconds();
                    console.log('end Date'+ end);
                    alert('Successfully set data');
                }, 2000);


You must log in to answer this question.

Browse other questions tagged .