> i am trying to access that element in javascript using:
> form.data[User][username].value

Just FYI, "form.data[User][whatever]" won't work in javascript because
javascript sees the brackets as parts of javascript arrays. So, rather
than look for that as a string, it's trying to evaluate it as nested
arrays, or rather objects, since that's how javascript does associative
arrays. Check this out:

form.data[User][username].value is the same as (using a php language
thing here)
form.data.the_value_of_the_js_variable_named_User.the_value_of_the_js_variable_named_Username

So, if you looked at the errors you got with your code, you see "User"
is undefined, because it can't find any variable in the JS name User.

When working with cake-generated inputs, I usually use the id, either
as RosSoft suggested with the prototype library, or get bibek's
document.getElementById.

However, that objects-as-associative-arrays thing works both ways. You
can use the name, by using it in an array. form.whatever is the same as
form['whatever']. So, to answer your question succinctly:

Reference it as an array. form['data[User][username]'].value


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---

Reply via email to