This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes having problems with javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "having problems with javascript" Watch "having problems with javascript" New topic
Author

having problems with javascript

jeyakanth yogaratnam
Greenhorn

Joined: Jun 25, 2005
Posts: 9
hello there

how do i assign values in struts-html property with the javascript var attribute. For example how do i assign the value in the below javascript var attribute,



my struts-html tag is " html:hidden property="paymentAmount" "

Now how do i assign the paymentAmount value with the grandTotal variable.
When i was using the input attribute in the normal html it was working fine.
Please help me regarding this matter.

thanks
jeyakanth
Karthik Subbaiah
Greenhorn

Joined: May 24, 2007
Posts: 1
Try using the below piece of code.
var grandTotal = some-value;
document.getElementsByName("paymentAmount")[0].value = grandTotal;

Alternatively, if you have the property associated with a form then you can write,
document.forms[0].paymentAmount.value = grandTotal;
jeyakanth yogaratnam
Greenhorn

Joined: Jun 25, 2005
Posts: 9
hello

the solution you gave is not working. The value is not getting stored into the form bean. As i when i retrieve the value from the logger only the default value is getting posted. Any idea regarding this, any suggestion. Please help me.

regards
jeyakanth
Ryan Zielke
Greenhorn

Joined: Jun 11, 2007
Posts: 1
Did you ever figure out what was going on. I am having the same issue. Works with FF but fails with IE
 
 
subject: having problems with javascript
 
Similar Threads
Assign Javascript value to JSP var
Dynamically Mapping Form Action with javascript
get string values from Request and Session
Javascript createTextNode
Drop Down Box in Struts - Select Default Value Implementation