Skip to content Skip to sidebar Skip to footer

Calling A Functions Value

Possible Duplicate: Function triggering early I have whipped up this code, but why on earth would it be alerting me that its undefined even though I have never even got a chance

Solution 1:

onSelect is an event callback, you are trying to return a value before it knows what to do. it's not going to be possible to have your test() return the value, because it comes later.

you should do your alert or whatever logic from within the event callback:

$('#d1').datepicker({
    onSelect: function() {
        sdate = $(this).val();
        $("#dd").dialog("close");
        alert(sdate);
        // or your own function
        someOtherTest(sdate);
    }
});

-

function someOtherTest(date) {
    alert(date);
}

Post a Comment for "Calling A Functions Value"