Monday, May 30, 2005 - 23:13

Javascript help?!

I need some javascript help. I'm trying to modify a script that I found on the web; all it does is load the specified url into the specified iframe. What I'm trying to do is make it take a list of iframes and a list of urls, and load each url into its corresponding iframe. This is proving surprisingly difficult, although admittedly I know effectively nothing about javascript.

This is the relevant portion of my script so far:


function loadintoIframe(frameids, urls)
{
var id_list = frameids.split("~")
var url_list = urls.split("~")
for (i=0; i < id_list.length-1; i++)
{
if (document.getElementById)
document.getElementById(id_list[i]).src=url_list[i]
}
}


The parsing works; and if I comment out the loop and manually load either id_list[0] (and url_list[0]) or id_list[1] and url_list[1], it works fine. If I manually load id_list[0], url_list[0] and then manually load id_list[1], url_list[1] it works fine. It's only when I try to load both in the for loopthat it doesn't work - only the first one gets loaded. I've run it through a javascript debugger, and both statements are being executed; it's just not actually loading the second time round the loop.

What am I missing? It must be something basic ... Please, if you have any idea why this might happen, let me know!

Labels:

0 Comments:

Post a Comment

<< Home