469,271 Members | 1,009 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,271 developers. It's quick & easy.

error "Missing ] after element list" error in FireFox

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,locatio n=no,status=no,directories=no,toolbar=no,scrollbar s=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 23 '05 #1
1 18238
Lee
so***********@yahoo.com 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,locati on=no,status=no,directories=no,toolbar=no,scrollba rs=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.

Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by lisa.bogart | last post: by
1 post views Thread by Francesco Moi | last post: by
11 posts views Thread by kimiraikkonen | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.