Forum Moderators: open

Message Too Old, No Replies

Selecting the value of a x[j] id with ajax

         

Lussay

6:10 pm on Aug 16, 2010 (gmt 0)

10+ Year Member



Hi there,

First of all I would want to salute everyone here on the forums.

I have started learning javascript,jquery and ajax for about 1 week and so far everything was pretty clear.

Now I have stumbled into a problem and if it will not be to much derranje I will ask for some help here since I'm going in circles for about 2 hours.

I have a php script that generate a couple of selects like this :

<select id="id[4]" name="id[4]">
<option value="28">test1</option>
<option value="29">test2</option>
<option value="30">test3</option>
</select>


Now I am trying to get the value of this select for example with :


var firstValues = $('#id[4] :selected').val();

alert(firstValues);


But he alert that I am getting is null.

If I try this with some normal text like color, type etc instead of id[4] than it works. So I am not sure what the problem is.

Thank you very much,

Lucian

astupidname

10:32 am on Aug 17, 2010 (gmt 0)

10+ Year Member



Hi Lussay, and welcome to webmasterworld!
Just to point out that brackets '[' or ']' are not valid in an id attribute, so that may be the problem I guess.