Hi,
I would like to show an image depending of a date choosen on datepicker.
First step i have added in functions.php of my theme:
wp_enqueue_script('jquery-ui-datepicker');
wp_enqueue_style('jquery-style', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css');
Then in page.php of my theme i have added the function below:
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery('#MyDate').datepicker({
dateFormat : 'DD, d MM, yy',
numberOfMonths: 2,
inline: true,
minDate : -7,
maxDate : +30,
altField: '#MyDate_value',
onSelect: function(){
var day1 = $("#MyDate").datepicker('getDate').getDate();
var month1 = $("#MyDate").datepicker('getDate').getMonth() + 1;
var year1 = $("#MyDate").datepicker('getDate').getFullYear();
var fullDate = year1 + "-" + month1 + "-" + day1;
var str_sortie = "<img src=\"http://www.adress.com/" + fullDate +".jpg\">";
image_sortie.innerHTML = str_sortie;
}
});
});
</script>
3) In a wordpress page i have added
<!-- Datepicker -->
<div id="MyDate"></div>
<p>Image selected of the date <input type="text" id="MyDate_value" /></p>
<div id="image_sortie" style="text-align:center; margin-top:10px; margin-bottom:20px;"></div>
As a result on the page:
- i have the datepicker calendar for 2 months
- when i click on a date i have this date showed on the date picker box
- but i haven't got the image selected shown. My link is good because if i write <img src="http://www.adress.com/2014-10-01.jpg" /> for exemple for the picture of the 1st of octobre, i have got the picture showed.
I try to search but i don't find anything. If somebody understand in wich line the problem could be, could you exmplain me what to do ?
Thank you a lot and excuse me for my english.