hi
got a bit stuck on this...
function changeDay(newDay){
ajaxCall('tools/refresh_booking_visual.php','start=' + newDay,
function(x){
var pieces = eval("(" + x + ")");
document.getElementById('booking_visual').innerHTML = pieces.visual;
document.getElementById('booking_date').innerHTML = pieces.date;
document.getElementById('date_back').onclick = changeDay(pieces.backdate);
document.getElementById('date_next').onclick = changeDay(pieces.nextdate);
}
);
}
My code is to do with a calendar, when the user clicks the 'Next Day' button it calls the changeDay(), which then uses an ajax call to fetch the calendar details as a json object... shown as pieces.visual, and the new date pieces.date. However in order to call this changeDay function I have been using the onclick event, coded into the html, and now I need to reset the 'back' and 'next' buttons so that they pass the correct unix timestamp to my changeDay()... I tried using
document.getElementById('date_next').onclick = changeDay(pieces.nextdate);
- but the seem to actually call the changeDay() again... i only want it to set it so that when i physically click the next button it fires again...
any ideas... should I rather use
<a href="javascript(changeDay(timestamp)">Next Day</a>
and then
document.getElementById('date_next').href = changeDay(pieces.nextdate);