Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

using javascript to get set value of property name with a '.' in it

 
Tanveer Rameez
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I have a textbox mapped to a formBean property.the html output of my struts JSP for that textbox is :
<input type="text" name="builderDetails.forename">

The '.' in the field name is because builderDetails is a attribute of object type Builder which again has a attribute forename.
Now I need a use the value of that field in a javascript . in the javascript, I refer the value of that field as :

where MyForm is the name of the form (and also name of the FormBean) containing the field.
I get javascript error saying 'forename is null or not an object'. Its the 'builderDetails.forename' name that javascript fails to recognize. For other properties say simple 'forename', the javascript works fine.

My question is , How do I use javascript to access fields having names like 'builderDetails.forename' or others with a '.' in the field name?

Thanx
Tanveer

[ May 04, 2005: Message edited by: Tanveer Rameez ]
[ May 04, 2005: Message edited by: Tanveer Rameez ]
 
Thomas Mcfarrow
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I would try

var myElement = document.getElementById("builderDetails.forename");
myElement.value ......

Regards.
 
Tanveer Rameez
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
many thanx. It worked.
[ May 04, 2005: Message edited by: Tanveer Rameez ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic