Note that there are some explanatory texts on larger screens.

plurals
  1. POgetDate with Jquery Datepicker
    text
    copied!<p>i am trying to get date from my implementation of jquery date picker, add it to a string and display the resulting image in my div. Something however is just not working. Can anyone check out the code and have a look at it? </p> <p>The code is supposed to take the date from date picker, combine it in a string which is to have the necessary code to display tag, images are located in /image and in the format aYY-MM-DD.png, new to this date picker and can't quite get it down yet.</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&gt; &lt;link type="text/css" href="css/ui-lightness/jquery-ui-1.8.custom.css" rel="stylesheet" /&gt; &lt;script type="text/javascript" src="js/jquery-1.4.2.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="js/jquery-ui-1.8.custom.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(function(){ // Datepicker $('#datepicker').datepicker({ dateFormat: 'yy-mm-dd', inline: true, minDate: new Date(2010, 1 - 1, 1), maxDate:new Date(2010, 12 - 1, 31), altField: '#datepicker_value', }); //hover states on the static widgets $('#dialog_link, ul#icons li').hover( function() { $(this).addClass('ui-state-hover'); }, function() { $(this).removeClass('ui-state-hover'); } ); }); //var img_date = .datepicker('getDate'); var day1 = $("#datepicker").datepicker('getDate').getDate(); var month1 = $("#datepicker").datepicker('getDate').getMonth() + 1; var year1 = $("#datepicker").datepicker('getDate').getFullYear(); var fullDate = year1 + "-" + month1 + "-" + day1; var str_output = "&lt;h1&gt;&lt;center&gt;&lt;img src=\"/images/a" + fullDate + ".png\"&gt;&lt;/center&gt;&lt;/h1&gt;&lt;br/&gt;&lt;br&gt;"; page_output.innerHTML = str_output; // writing the results to the div element (page_out) &lt;/script&gt; &lt;/head&gt; &lt;body style="background-color:#000;color:#fff;margin: auto auto;"&gt; &lt;!-- Datepicker --&gt; &lt;div id="datepicker"&gt;&lt;/div&gt; &lt;!-- Highlight / Error --&gt; &lt;p&gt;Date Value: &lt;input type="text" id="datepicker_value" /&gt;&lt;/p&gt; &lt;div id="page_output" style="text-align:center; margin-top:80px; margin-bottom:20px; "&gt;&lt;/div&gt; &lt;/body&gt; </code></pre> <p></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