Hi there,
I have a class that calls a dynamic countdown on my webpage.
when I call the class it looks like this.
A quick explanation: 'contain' is the div in which the class appears, and "April 21, 2011 12:55:55" is the future date set for countdown.
the 'days' and 'formatresults' is just the format that the countdown is displayed in.
now ideally what I am trying to do is instead of hard-coding my dates into my class like this, I want to pull the date from my database as a variable using Ajax. that function looks like this.
the variable myret contains the date variable that I want to use in my countdown class. i.e. I want to replace the hard-coded date with myret.
I know myret is returning the correct information cos I just inserted it into a test div.
but when I use it in my countdown class, it returns 'not defined' on my web page.
Please could someone help me, I have been trying to use firebug to see what is being called when but I am super confused!!
Thank you so much for your help
Avatar19
I have a class that calls a dynamic countdown on my webpage.
when I call the class it looks like this.
Code:
<script type='text/javascript'>
var futuredate=new cdtime("contain","April 21, 2011 12:55:55")
futuredate.displaycountdown("days", formatresults)
</script>
A quick explanation: 'contain' is the div in which the class appears, and "April 21, 2011 12:55:55" is the future date set for countdown.
the 'days' and 'formatresults' is just the format that the countdown is displayed in.
now ideally what I am trying to do is instead of hard-coding my dates into my class like this, I want to pull the date from my database as a variable using Ajax. that function looks like this.
Code:
<script type='text/javascript'>
var myret;
function get_bid(div_id)
{
if (div_id == 'contain')
{
var pass = 'apple_01';
}
else if (div_id == 'contain2')
{
var pass = 'mp3_01';
}
else if (div_id == 'contain3')
{
var pass = 'car_01';
}
else if (div_id == 'contain4')
{
var pass = 'blackberry_01';
}
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
var get_data = document.getElementById('test');
myret = xmlhttp.responseText;
get_data.innerHTML = myret;
}
}
xmlhttp.open("GET","bid_data.php?q="+pass,true);
xmlhttp.send(null);
}
</script>
Code:
var futuredate=new cdtime("contain",myret)
futuredate.displaycountdown("days", formatresults)
but when I use it in my countdown class, it returns 'not defined' on my web page.
Please could someone help me, I have been trying to use firebug to see what is being called when but I am super confused!!
Thank you so much for your help
Avatar19
Comment