Vehemence
asked on
Updating the innerHTML of a dynamically created/named SPAN tag
The only problem I'm really having with this code (although it may look butchered in other places, I know what I'm doing.. honest ;) ) is the updating of the dynamically created and named (with the current time) span tag with a 'new' string from the jd[] array. Is updating a dynamically created span tag (or div, for that matter) even possible? If so, HELP! :)
function banner() {}
jd = new banner() ; n = 0;
jd[n++]= '<A HREF="https://www.experts-exchange.com"><IMG SRC="http://www.mydomain/mybanner01.gif" border=0></A>';
jd[n++]= '<A HREF="https://www.experts-exchange.com"><IMG SRC="http://www.mydomain/mybanner02.gif" border=0></A>';
jd[n++]= '<A HREF="https://www.experts-exchange.com"><IMG SRC="http://www.mydomain/mybanner03.gif" border=0></A>';
i=Math.floor(Math.random() * n);
var day = new Date();
var somename = day.getTime();
document.write('<span STYLE="position: absolute;" id="' + somename +'">');
document.write(jd[i] + '<br><a href="javascript:bannercha nge(\''+so mename+'\' ,\''+i+'\' )">Click to update the banner</a>');
document.write('</span>');
function bannerchange(bannerspan,nu mb){
ns4 = (document.layers)? true:false
ie4 = (document.all)? true:false
var numbOne=i++;
var bCode=jd[numbOne];
if (!ie4) {
with (document[bannerspan].docu ment) {
open();
write(bCode + '<br><a href="javascript:bannercha nge(\''+so mename+'\' ,\''+i+'\' )">Click to update the banner</a>');
close();
}
}
else {
document.all[bannerspan].i nnerHTML = (bCode + '<br><a href="javascript:bannercha nge(\''+so mename+'\' ,\''+i+'\' )">Click to update the banner</a>');
}
}
function banner() {}
jd = new banner() ; n = 0;
jd[n++]= '<A HREF="https://www.experts-exchange.com"><IMG SRC="http://www.mydomain/mybanner01.gif" border=0></A>';
jd[n++]= '<A HREF="https://www.experts-exchange.com"><IMG SRC="http://www.mydomain/mybanner02.gif" border=0></A>';
jd[n++]= '<A HREF="https://www.experts-exchange.com"><IMG SRC="http://www.mydomain/mybanner03.gif" border=0></A>';
i=Math.floor(Math.random()
var day = new Date();
var somename = day.getTime();
document.write('<span STYLE="position: absolute;" id="' + somename +'">');
document.write(jd[i] + '<br><a href="javascript:bannercha
document.write('</span>');
function bannerchange(bannerspan,nu
ns4 = (document.layers)? true:false
ie4 = (document.all)? true:false
var numbOne=i++;
var bCode=jd[numbOne];
if (!ie4) {
with (document[bannerspan].docu
open();
write(bCode + '<br><a href="javascript:bannercha
close();
}
}
else {
document.all[bannerspan].i
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks, that seems to be all that was holding it back.. something I'll remember to look out for from now on (and would never have thought to check myself!)
I also think that the i isn't incremented the first time you call the function.
var numbOne=++i;
var numbOne=++i;
ASKER