Forum Moderators: open
document.getElementsByTagName('body')[0].onload = pageload;
function pageload() {
var sysPrice = 0;
var pricetext;
sysPrice = generateprice();
checkcompat();
pricetext = document.getElementById('sysprice');
pricetext.firstChild.data = ("$" + sysPrice);
}
Unless I'm missing something what I'm hoping to accomplish is to first link the body tag's onload event to the function pageload. Then once the event is triggered (onload) run the function. This should then update the textnode (the child of a span) to be the price calculated by generateprice().
It's not working...it might not even be running the function at all...so what has gone wrong?
*I should note that I'm using firefox with the firebug extension, it indicates that the onload event is registered with body...but I even hid an alert() in the function for a while and it never popped.
Here is a little function that takes an 'id' for a DIV or SPAN or A and changes the text it dynamically.
e.g. textmod('myid','New Text')
It works cross browser.
function textmod (elnam, newtext) {
// get reference to the element
var ttext = document.getElementById(elnam);
var new_txt = document.createTextNode(newtext);
ttext.replaceChild(new_txt, ttext.childNodes[0]);
}
Cheers,