View Full Version : Document.write problem with func parameters

02-02-2004, 03:51 PM
Can anyone help me with the following problem:
var menu = new Array(5);
menu[0] = new Array(5);
menu[0][0] = "nospace";
menu[0][1] = "one space";
for(i=0; i<5; i++){
document.write("<DIV id=" + "Header" + ">" + "<A href=" + "javascript:WOM_toggle('" + menu[i][0] + "')>" + menu[i][0] + "</A><img src='arrow_down.png' /></DIV>");
this creates a function call for menu[0][0] as
but for the second entry [0][1] it writes it out as

The rest of the text/string and the closing quote is missing????

Roy Sinclair
02-02-2004, 05:39 PM
Try this:

document.write("<div id=\"Header" + i + "\">" + "<a href=\"java\script:WOM_toggle('" + menu[i][0] + "')\">" + menu[i][0] + "</a><img src=\"arrow_down.png\" /></div>");

Your loop was incorrectly creating multiple items with the same "id" value which isn't legal and you weren't getting the quote marks around your href in the a tag.

02-03-2004, 09:16 AM
Roy, thanks for your help.

The code is working now! the duplicate ID's are ok as I just roughly typed in the code, was mainly hoping to get some help why the qoute marks were not working, but after adding the \ all seems fine now. Thanks a lot!

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum