Hi Tomm, back again. I have some progress, but I think I need some help here.
What am I trying to do?
I am trying to update the contents of my graph when a user picks a date.
I have a graphs page, showing downloaded items today - the php query is as in the snippet:
Code:
require_once MYBB_ROOT."inc/3rdparty/ofc_charts/open-flash-chart.php";
$mydate=date("Ymd", (TIME_NOW-(60*60*24*2)));
$days = $tids = array();
$query = $db->simple_select("threads", "tid, subject, dateline", "uid = '".$mybb->user['uid']."'");
if($db->num_rows($query))
{
$date = $mydate;
bla bla bla
The var $mydate gets passed into the query and all goes as planned. I am trying to make it so that when a user selects a date from the jQuery datepicker then the variable $mydate in the php query changes and then I can refresh the graph. This is my datepicker setup, it sets the date to the correct format as in my database table (example date format in the db = 20110428)
Code:
<script>
jQuery(document).ready(function() {
jQuery( "#datepicker").datepicker({
showOn: "button",
buttonImage: "{$mybb->settings['bburl']}/images/toplinks/calendar.gif",
buttonImageOnly:true,
minDate: -30, maxDate: 0,
dateFormat: "yymmdd",
constrainInput: true,
onSelect: function(dateText, inst) {document.getElementById('mydate').value=dateText; }
});
});
</script>
and this is what I have in my HTML to make the datepicker show:
Code:
<form method="get" action=" " value="mydate" name="mydate" id="mydate">
<input type="text" id="datepicker">
</form>
As you can see the action bit is empty as I don't know what to put there
I have managed to make my graph reload on a timer using AJAX to get real time data. Not that I want it to reload like that, but it shows I can manipulate the chart object. This is the timer code:
Code:
<script>
var timerID = 0;
function reload()
{
if (timerID)
{
clearTimeout(timerID);
}
tmp = findSWF("my_chart");
x = tmp.reload("xmlhttp.php?action=get_upload_info");
timerID = setTimeout("reload()", 3000);
}
function findSWF(movieName)
{
if (navigator.appName.indexOf("Microsoft")!= -1)
{
return window[movieName];
}
else
{
return document[movieName];
}
}
timerID = setTimeout("reload()", 3000);
</script>
Ideally I want it to reload once the date is submitted via the datepicker to the leegraphs2.php file.
So, my questions are:
How do I make the mydate variable in the php file update via the jQuery Datepicker?
What variable should I use in my AJAX reload to make it work via the submission of the date in the datepicker rather than a timer?