This one is scheduled for a tips page someplace. I'm adding it to my 
site, but Struts home page should have one... anyways, onto the real 
topic....

As you already know, the dot notation is getting in the way and messing 
up JavaScript document object model.

For the field you want, use...

document.forms[0]["address.number"]

...so to alert it's value...

document.forms[0]["address.number"].value

...to pull focus...

document.forms[0]["address.number"].focus()

You get the idea. All it needs is a string. So the following is the same 
and makes things handy...

var myVar = "addrss.number"
document.forms[0][myVar]

And naturally you can access and field in this way to make your scripts 
run on a standard.

Implications: none. it's cross browser. So go play :)


Arron.


Frederico Schuh wrote:

>I'm using nested beans inside my ActionForms, and thus
>I have to reference those bean properties with dots
>(like address.number) in the JSP file. So, the
>generated HTML would be something like this:
>
><form name="myForm" action="/something.do">
>   <input type="text" name="address.number">
></form>
>
>The problem is that I can't find a way to reference
>those form fields if I want to do some javascript
>validation. If I do something like
>"document.forms[0].address.number" it doesn't work.
>How do I do it?
>
>
>=====
>----------------------------------------
>Frederico Ferro Schuh
>[EMAIL PROTECTED]
>ICQ: 20486081
>
>_______________________________________________________________________________________________
>Yahoo! Empregos
>O trabalho dos seus sonhos pode estar aqui. Cadastre-se hoje mesmo no Yahoo! Empregos 
>e tenha acesso a milhares de vagas abertas!
>http://br.empregos.yahoo.com/
>
>--
>To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
>For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>
>



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to