The obvious solution was to move the javascript code into the php file, and then just echo in the wanted date. The code below does this, and the commented out line shows how it worked before in the script file. There was probably an easier way, but this works.
<?php// This section sets the datepicker day to the selected dayecho '<script type="text/javascript">// jQuery ready function. Specify a function to execute when the DOM is fully loaded.$(document).ready(// This is the function that will get executed after the DOM is fully loadedfunction () {console.log("ready 0987520933");$( "#datepicker" ).datepicker({changeMonth: true,//this option for allowing user to select monthchangeYear: true //this option for allowing user to select from year range});var today = new Date();console.log("08"+"/"+today.getDate()+"/"+today.getFullYear());//$( "#datepicker" ).datepicker("setDate",(today.getMonth()+1)+"/"+today.getDate()+"/"+today.getFullYear());$( "#datepicker" ).datepicker("setDate",' . $month . '+"/"+ ' . $day . '+"/"+' . $year . ');});</script>';?>
Unfortunately I've noticed that the website is getting slower to load. I don't have the skills right now to improve this, but I'll have to think about it in the future. The next thing I'm thinking about adding is a boxscore, or list of scoring plays. And the long-term goal is to give the site memory of what you visited and store a list of highlights so it doesn't have to get the XML page from MLB every time.
No comments:
Post a Comment