By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
460,043 Members | 1,148 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 460,043 IT Pros & Developers. It's quick & easy.

missing ] after element list

P: n/a
I am attempting to populate a few select drop down menus from the
selection of the first drop down. I am using ajax to submit data via a
PHP GET and from the response populate the other drop down menus.

I figured out how to get it to do so for more than one drop down, but I
am getting the following error below. This was working fine until I
tried to populate more than one other drop down menu. Any idea why the
SELECT object isn't being passed? It seems so close.

Thanks,
Pasquale
*** begin error ***
missing ] after element list
GetInfo([object HTMLSelectElement],1,"Color") Line 82
-----------------|
*** end error ***

*** begin JavaScript snip ***
var attr;
var attrarray = new Array (
'Color','Type'
);
function InfoLoop (sel,selset) {
for (var i = 0; i < attrarray.length; i++) {
attr = attrarray[i];
setTimeout('GetInfo('+sel+','+selset+',"'+attr+'") ',2000); //Line 82
}
}
*** end JavaScript snip ***

*** begin HTML snip ***
<SELECT id="Collection_1" name="Collection_1" size="1"
onChange="InfoLoop(this,1)">
*** end HTML snip ***
Jun 23 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Lee
Pasquale said:
>
I am attempting to populate a few select drop down menus from the
selection of the first drop down. I am using ajax to submit data via a
PHP GET and from the response populate the other drop down menus.

I figured out how to get it to do so for more than one drop down, but I
am getting the following error below. This was working fine until I
tried to populate more than one other drop down menu. Any idea why the
SELECT object isn't being passed? It seems so close.

Thanks,
Pasquale
*** begin error ***
missing ] after element list
GetInfo([object HTMLSelectElement],1,"Color") Line 82
-----------------|
*** end error ***

*** begin JavaScript snip ***
var attr;
var attrarray = new Array (
'Color','Type'
);
function InfoLoop (sel,selset) {
for (var i = 0; i < attrarray.length; i++) {
attr = attrarray[i];
setTimeout('GetInfo('+sel+','+selset+',"'+attr+'") ',2000); //Line 82
}
}
*** end JavaScript snip ***

*** begin HTML snip ***
<SELECT id="Collection_1" name="Collection_1" size="1"
onChange="InfoLoop(this,1)">
*** end HTML snip ***
You're passing a reference to the Select object into infoLoop(),
and inside that function you're using that argument in a string
concatination. In order to do that, Javascript uses the value
of the Select object's toString() method, which seems to be
"[object HTMLSelectElement]".

Instead of passing a reference to the Select, pass its id value,
which can safely be concatinated into a string. You'll also
have to make changes to infoLoop() and GetInfo() so they treat
the value correctly.
--

Jun 23 '07 #2

P: n/a
Lee
Lee said:
>You're passing a reference to the Select object into infoLoop(),
and inside that function you're using that argument in a string
concatination. In order to do that, Javascript uses the value
of the Select object's toString() method, which seems to be
"[object HTMLSelectElement]".

Instead of passing a reference to the Select, pass its id value,
which can safely be concatinated into a string. You'll also
have to make changes to infoLoop() and GetInfo() so they treat
the value correctly.
I find it really annoying that, after all these years of
using the word, my fingers still haven't learned to spell
"concatenate" correctly.
--

Jun 23 '07 #3

P: n/a
Lee wrote:
Lee said:
>You're passing a reference to the Select object into infoLoop(),
and inside that function you're using that argument in a string
concatination. In order to do that, Javascript uses the value
of the Select object's toString() method, which seems to be
"[object HTMLSelectElement]".

Instead of passing a reference to the Select, pass its id value,
which can safely be concatinated into a string. You'll also
have to make changes to infoLoop() and GetInfo() so they treat
the value correctly.

I find it really annoying that, after all these years of
using the word, my fingers still haven't learned to spell
"concatenate" correctly.
Hahaha. I thank the Mozilla gods everyday for Thunderbirds "spell check
as you type" feature.

--
-Lost
Remove the extra words to reply by e-mail. Don't e-mail me. I am
kidding. No I am not.
Jun 23 '07 #4

P: n/a
Lee wrote:
>>
*** begin JavaScript snip ***
var attr;
var attrarray = new Array (
'Color','Type'
);
function InfoLoop (sel,selset) {
for (var i = 0; i < attrarray.length; i++) {
attr = attrarray[i];
setTimeout('GetInfo('+sel+','+selset+',"'+attr+'") ',2000); //Line 82
}
}
*** end JavaScript snip ***

*** begin HTML snip ***
<SELECT id="Collection_1" name="Collection_1" size="1"
onChange="InfoLoop(this,1)">
*** end HTML snip ***

You're passing a reference to the Select object into infoLoop(),
and inside that function you're using that argument in a string
concatination. In order to do that, Javascript uses the value
of the Select object's toString() method, which seems to be
"[object HTMLSelectElement]".

Instead of passing a reference to the Select, pass its id value,
which can safely be concatinated into a string. You'll also
have to make changes to infoLoop() and GetInfo() so they treat
the value correctly.
Thanks! That is fixed, but now the ' attr = attrarray[i]; ' is
processing before the return of the PHP data. So the options are put
into the second of the attributes drop down instead of the first.

Thinking about, it would probably be better to wait until
the return of the PHP data is done and then have attr = attrarray[i];
process.

But out of curiousity, can I setTimeout to ' attr = attrarray[i]; ' to
have it pause for a second?

>
Jun 24 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.