Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery UI Datepicker and var
    text
    copied!<p>I can't seem for the life of me to get this working. Basically the scenario goes like this. I have a function that gets executed and pops up a jQuery dialog window with a datepicker embedded in it. The user selects a date and presto, the date gets chosen and an automated message is captured into a var. The problem is that when the same type of code is executed again, the sdate changes but the text remains the same with a new date. I'd like to have dynamic text with a dynamic date. This is tricky because I know that the datepicker is a call back function, which is basically beyond my knowledge of javascript coding.</p> <pre><code>&lt;div style="display:none" id="dd"&gt; &lt;div id="d1"&gt;&lt;/div&gt; &lt;/div&gt; </code></pre> <p>eg. test('1') test('2')</p> <pre><code>var sdate, text //========================================================================== function test(x) { //========================================================================== if (x == '1') { $('#dd') .dialog({ autoOpen: true, modal: true, overlay: { opacity: 1.0, background: 'black' }, title: "SELECT DATE 1...", height: 235, width: 235, draggable: false, resizable: false }); $('#d1') .datepicker({ onSelect: function () { sdate = $(this) .val(); $("#dd") .dialog("close"); text = 'THE DATE YOU HAVE CHOSEN IS: ' + sdate + '.' alert(text) } //end of onSelect: function() { }); //end of datepicker } //end of (x == '1') else if (x == '2') { $('#dd') .dialog({ autoOpen: true, modal: true, overlay: { opacity: 1.0, background: 'black' }, title: "SELECT DATE 2...", height: 235, width: 235, draggable: false, resizable: false }); $('#d1') .datepicker({ onSelect: function () { sdate = $(this) .val(); $("#dd") .dialog("close"); text = 'THE 2ND DATE YOU HAVE CHOSEN IS: ' + sdate + '.' alert(text) } //end of onSelect: function() { }); //end of datepicker } //end of (x == '2') } //end of function </code></pre> <p>Going crazy and need the help of the experts on this forum.</p> <p>Much thanks and appreciation for all your help an support</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload