error "Missing ] after element list" error in FireFox

Discussion in 'Javascript' started by soup_or_power@yahoo.com, Jul 5, 2005.

  1. Guest

    I'm passing the return from window.open as a function argument and
    getting the error "missing ] after element list" when tested with
    FireFox. Here is the relevant code. Many thanks for your help.

    function blurCkbox(num, disp, but_id, sugg)
    {
    if (num == 1) {
    eval("self.opener.document.forms[0]." + but_id + ".value=\'" +
    sugg + "\'");

    }
    function showSugg(but_id, sugg1, sugg2, sugg3, sugg4, sugg5) {


    var
    display=window.open('','_blank','menubar=0,location=no,status=no,directories=no,toolbar=no,scrollbars=yes,height=110,width=190')
    var message="<font face='verdana, arial, helvetica, san-serif'
    size='2'><form>";
    message += sugg1 + "<input type=checkbox name=mycheck1
    value=\'" + sugg1 + "\' onClick=\"blurCkbox('1'," + display + "," +
    but_id + ",\'" + sugg1 + "\')\">";

    }
    , Jul 5, 2005
    #1
    1. Advertising

  2. Lee Guest

    said:
    >
    >I'm passing the return from window.open as a function argument and
    >getting the error "missing ] after element list" when tested with
    >FireFox. Here is the relevant code. Many thanks for your help.
    >
    >function blurCkbox(num, disp, but_id, sugg)
    >{
    > if (num == 1) {
    > eval("self.opener.document.forms[0]." + but_id + ".value=\'" +
    >sugg + "\'");
    >
    >}


    There's no need to use eval() there:

    if (num == 1) {
    opener.document.forms[0].elements[but_id].value=sugg;
    }

    I notice that blurCkbox has a formal parameter "disp" that
    is never used.


    >function showSugg(but_id, sugg1, sugg2, sugg3, sugg4, sugg5) {
    >
    >
    > var
    >display=window.open('','_blank','menubar=0,location=no,status=no,directories=no,toolbar=no,scrollbars=yes,height=110,width=190')
    >var message="<font face='verdana, arial, helvetica, san-serif'
    >size='2'><form>";
    > message += sugg1 + "<input type=checkbox name=mycheck1
    >value=\'" + sugg1 + "\' onClick=\"blurCkbox('1'," + display + "," +
    >but_id + ",\'" + sugg1 + "\')\">";
    >
    >}


    You're not passing the return value of window.open() as a function
    argument. You're concatinating it into a string named "message".
    When you concatinate an Object (a Window object, in this case)
    with strings, it is converted to a string by its toString() method.
    The default method that would be used in this case converts the
    Object to the string "[Object]", which creates a syntax error.
    Lee, Jul 5, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. VK
    Replies:
    9
    Views:
    91
  2. Steve Chapel
    Replies:
    15
    Views:
    228
  3. Pasquale

    missing ] after element list

    Pasquale, Jun 23, 2007, in forum: Javascript
    Replies:
    4
    Views:
    144
    Pasquale
    Jun 24, 2007
  4. Rahul Mehta

    missing ] after element list

    Rahul Mehta, Aug 23, 2010, in forum: Javascript
    Replies:
    8
    Views:
    1,043
    Garrett Smith
    Aug 25, 2010
  5. zephyr

    missing ] after element list

    zephyr, Apr 6, 2011, in forum: Javascript
    Replies:
    4
    Views:
    409
    Gregor Kofler
    Apr 7, 2011
Loading...

Share This Page