Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8461101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:47:12+00:00 2026-06-10T13:47:12+00:00

I need the help of the experts on here. When I call the function

  • 0

I need the help of the experts on here.

When I call the function v9_insert_comments(‘1’) the alert(sdate) triggers before I even get to select a date in the datepicker.

My goal is to have the v9_insert_comments() check to see if the sdate is null or not. If its null then just { return } if not { do something else }.

The current case if that sdate is always null because the datepicker never gets a chance to set it.

var sdate

//========================================================================
  function v9_insert_comments(x) {
//========================================================================

    if (x == 1) {
            select_date()
            alert(sdate)
    }


}//end of function


//========================================================================
  function select_date() {
//========================================================================
    $('#dd').dialog({
        autoOpen: true,
        modal: true,
        overlay: {
            opacity: 0.5,
            background: 'black'
        },
        title: "title",
        height: 265,
        width: 235,
        draggable: false,
        resizable: false

    }); //end of dialog

    $('#d1').datepicker({
        onSelect: function() {
            sdate = $(this).val();
            $("#dd").dialog("close");

        }
    });

} //end of function

Body:

<!-- START OF DATE SELECTOR DIALOG -->
<div style="display:none" id="dd">
<div id="d1"></div>
</div>
<!-- END OF DATE SELECTOR DIALOG -->
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T13:47:13+00:00Added an answer on June 10, 2026 at 1:47 pm

    In your select_date method you’re just setting stuff up. The call to $('#dd').dialog() does all the jQuery UI magic to create a dialog, by updating the DOM and wiring things up. Then you call $('#d1').datepicker(), which sets up a datepicker in a similar way. It’s just saying “this div is now a dialog, and this div is now a datepicker”. It’s not waiting for any user interaction. Your v9_insert_comments function is assuming things are happening synchronously, whereas they’re actually happening asynchronously.

    After these things are set up, you immediately ask for the value of a variable that hasn’t been set yet. It hasn’t been set because the anonymous function you supplied for the datepicker’s onSelect event hasn’t fired yet. This function will only be called when something has been selected in the datepicker. So if you want to do something with the selected date, do it in the event handler.

    You could move your alert to the event handler, or you could call v9_insert_comments from the event handler – but in this case you should move the call to select_date elsewhere. The dialog and datepicker only need to be set up once.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Need help, function getFamily() { FB.api('/me/family', function(response) { alert(JSON.stringify(response)); }); } With the above
Iam bit new to SpringMVC REST concept. Need a help from experts here to
I need the help of the experts on here. My code is fine and
Silverlight experts out there, I need some help. I used Deep Zoom Composer to
need help to create regular expression matching string www.*.abc.*/somestring Here * is wild card
need help/guide for sql select query, I have 2 table stock and stock_history, in
Once again I need some much appreciated help from the experts :) I am
I am no expert in Flash, and I need some quick help here, without
I need a regex expert to help out on this one. Examples I've found
Need help with a query that I wrote: I have three tables Company id

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.