SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast bbmx952's Avatar
    Join Date
    Feb 2005
    Posts
    31
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up (!FIXED!)Having problems getting dynamicly created Drop Down Menu to work properly

    Ok, I have a drop down menu that fires a function and it is supposed to create another drop down menu which then writes in a <div>. The problem is that when I try and use the second drop down menu it wont fire the action, it gives me "Error: missing ; before statement", and I see what it is thinking but Im not sure how to fix it.
    Code:
    var selectmenu2 = '<form name="form2"><select name="menu2" onChange="MM_jumpMenu('parent',this,0)"><option value="javascript:showtext()">Option1</option>';
    function m2o2() {
    document.getElementById("area3").innerHTML = selectmenu2;
    }
    The problem is within "var selectmenu2", it thinks that Im trying to say:
    Code:
    var selectmenu2 = '<form name="form2"><select name="menu2" onChange="MM_jumpMenu(';
    
    parent',this,0)"><option value="javascript:showtext()">Option1</option>';
    So, any sugestions?
    Last edited by bbmx952; Feb 11, 2005 at 14:40. Reason: !Problem Fixed!

  2. #2
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Portsmouth UK
    Posts
    1,499
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    need to escape / internalcharactors ' as charactor ' used to define the string

    PHP Code:
    var selectmenu2 '<form name="form2"><select name="menu2" onChange="MM_jumpMenu(\'parent\',this,0)"><option value="javascript:showtext()">Option1</option>'
    this assums that parent is a string value

  3. #3
    SitePoint Enthusiast bbmx952's Avatar
    Join Date
    Feb 2005
    Posts
    31
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, that fixed that problem, now that brought about another problem (isn't that how it always is? lol) anyways, the problem is that its it says "Function Expected" but I have the function its:
    Code:
    function MM_jumpMenu(targ,selObj,restore){
      eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
      if (restore) selObj.selectedIndex=0;
    }
    any ideas on whats going on now?

  4. #4
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I dont think that this is going to work:

    parent.location='javascript:showtext()';

    It gives me an error also.

  5. #5
    SitePoint Enthusiast bbmx952's Avatar
    Join Date
    Feb 2005
    Posts
    31
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Cool

    OMG, I figured it out, Im so stupid, lol my original post is just an example of what I have, but in my drop down menu that is created buy my first drop down menu, I was linking it to my var and not my function, lol, Im so stupid thanks for the help though.


Bookmarks

Posting Permissions

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