Javascript problem with name tag (name => 'address[street]')

Hi All

I just noticed that I don’t really know how to deal with the names which
are needed by Rais, for example, with textfield, like
<%= text_field(“address”, “street”, “size” => 10, “name”
=>“address[street]”) %>

I need to set the focus to this textfield, but Javascript doesn’t seem
to be happy at all with the following call:
document.regform.address[street].focus()

Any suggestions how to do this ?

Thanks a lot
LuCa

Any suggestions how to do this ?

Well, if you’ve got the prototype library loaded up you could do:

$(‘address_street’).focus();

This works because rails will give that text field an id of
“address_street”…

Otherwise you can do:

document.regform.elements[“address[street]”].focus();

-philip

hi

the javascript example is perfect!. The prototype lib is new for me, it
looks very interesting!!

thnx a lot
LuCa