Note that there are some explanatory texts on larger screens.

plurals
  1. POJquery Datepicker with XML file
    primarykey
    data
    text
    <p>an extension of my last question, <a href="https://stackoverflow.com/questions/2562986/getdate-with-jquery-datepicker">getDate with Jquery Datepicker</a> , </p> <p>I am trying to use the jquery datepicker to load specific info from xml file dependent on the date selected by the user. Similar code but i am trying to load and parse an xml file to read contents of the file for the particular date.</p> <p>In a perfect world the user would tap a date and below the datepicker html output would give the user specific times for the selected date instead of my last project of an image.</p> <p>my probelm is nothing is loading, so my question is what am i doing wrong?</p> <p>my code is as follows</p> <pre><code>&lt;!DOCTYPE html&gt; </code></pre> <p> </p> <pre><code> &lt;link type="text/css" href="css/ui-darkness/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', onSelect: function(){ 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;img src=\"http://website/images/a" + fullDate +".png\" width=\"100%\"/&gt;"; //"&lt;h1&gt;"+fullDate+"&lt;/h1&gt;"; //"&lt;img src=\"http://website/images/a" + fullDate +".png\"/&gt;"; //$('#page_output').html(str_output); var doc = loadXMLDoc('date.xml'); // loading the XML file var el = doc.getElementsByTagName('_'+date); // retrieving the elements corrsponding to a date, eg: _20100103 var page_output = document.getElementById('page_output'); if(el.length &gt;= 1) { // matched XML data found for the specified date var dt = el[0].getElementsByTagName('date'); var great_times = el[0].getElementsByTagName('great_times'); var good_times = el[0].getElementsByTagName('good_times'); var str_output = "&lt;h1&gt;&lt;center&gt;" + dt[0].childNodes[0].nodeValue + "&lt;/center&gt;&lt;/h1&gt;&lt;br/&gt;&lt;br&gt;"; str_output += "&lt;b&gt;Excellent Times:&lt;/b&gt;&lt;br&gt; " + great_times[0].childNodes[0].nodeValue + "&lt;br/&gt;&lt;br&gt;"; str_output += "&lt;b&gt;Good Times:&lt;/b&gt;&lt;br&gt; " + good_times[0].childNodes[0].nodeValue + "&lt;br/&gt;&lt;br&gt;"; $('#page_output').html(str_output);// writing the results to the div element (page_out) } else { alert("Sorry","Action not allowed on this page"); page_output.innerHTML = ''; // No XML data found for the selected date reloadmainwDate(); return false; } return true; } }); //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 date = $('#datepicker').datepicker({ dateFormat: 'dd-mm-yy' }); //var str_output = "&lt;h1&gt;&lt;center&gt;&lt;p&gt;"+ date + "&lt;/p&gt;&lt;/center&gt;&lt;/h1&gt;"; //$('#page_output')[0].innerHTML = str_output; // writing the results to the div element (page_out) &lt;/script&gt; &lt;script&gt; </code></pre> <p>function loadXMLDoc(dname) { var xmlDoc;</p> <pre><code>// IE 5 and IE 6 if(typeof ActiveXObject != 'undefined') { xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async=false; xmlDoc.load(dname); return xmlDoc; } else if (window.XMLHttpRequest) // firefox { xmlDoc=new window.XMLHttpRequest(); xmlDoc.open("GET",dname,false); xmlDoc.send(""); return xmlDoc.responseXML; } alert("Error loading document"); return null; </code></pre> <p>} </p> <p> </p> <pre><code> &lt;!-- Datepicker --&gt; &lt;div id="datepicker"&gt;&lt;/div&gt; &lt;!-- Highlight / Error --&gt; &lt;div id="page_output"&gt;&lt;/div&gt; &lt;/body&gt; </code></pre> <p></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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