Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Feb 2004
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Document.write problem with func parameters

    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
    javascript:WOM_toggle('nospace')
    but for the second entry [0][1] it writes it out as
    javascript:WOM_toggle('one

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

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Try this:

    Code:
    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.
    Last edited by Roy Sinclair; 02-02-2004 at 05:41 PM.
    Check out the Forum Search. It's the short path to getting great results from this forum.

  • #3
    New to the CF scene
    Join Date
    Feb 2004
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile

    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!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •