aspose file tools*
The moose likes Struts and the fly likes using javascript to get set value of property name with a '.' in it Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "using javascript to get set value of property name with a Watch "using javascript to get set value of property name with a New topic
Author

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

Tanveer Rameez
Ranch Hand

Joined: Dec 11, 2000
Posts: 158
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 ]

Author of JPhotoBrush Pro (www.jphotobrushpro.com)
Thomas Mcfarrow
Ranch Hand

Joined: Jul 09, 2001
Posts: 137
Hello,

I would try

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

Regards.
Tanveer Rameez
Ranch Hand

Joined: Dec 11, 2000
Posts: 158
many thanx. It worked.
[ May 04, 2005: Message edited by: Tanveer Rameez ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: using javascript to get set value of property name with a '.' in it
 
Similar Threads
java as user interface
Changing options(contents) of a select element in Struts' jsp form
Pass values from Servlet to Custom Tag
please help me
How to launch JInternalFrame from a JTabbedPane