PDA

View Full Version : Function triggering before I select a date in datepicker



jason_kelly
08-30-2012, 03:45 PM
Hello,

I really 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