views:

139

answers:

3

I want to select an input with Prototypejs and its $$ function.

I am able to do this :

$$('input')

But I want to be more accurate in my search, with a name of an input. The name of the input I want to select is "array[]" :

$$('input[name="array[]"]')

I think the [ and ] in the name are creating troubles because the result I get are the same as if I did this :

$$('input')

How do i select the inputs having a name such as "something[]" ?

+2  A: 

You can be a little more verbose and use :

$$('input').findAll(function (o) { return o.name=="array[]"; })
Alsciende
Yeah, I was hoping to be able not to do that.
kevin
A: 

Are you probably looking for

$$('input[name="array[]"]')[0]

because $$() returns an array of input elements? Works for me.

andre-r
Works for me too but as I described it returns every input elements in the document.I want an array of the elements having the name array[], not the others.
kevin
Doesn't seem to work with prototype selectors. Btw, `$('input[name="array[]"]')` works in jQuery.
andre-r
+1  A: 

It seems like it was a bug with prototype 1.6.0.3 and probably lower versions.

Works with prototype >= 1.6.1

kevin