This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Struts and the fly likes Updating actionfrom using javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Updating actionfrom using javascript" Watch "Updating actionfrom using javascript" New topic
Author

Updating actionfrom using javascript

James Winfrey
Ranch Hand

Joined: Jan 04, 2009
Posts: 60
Hi Guys

Can I set the values of actionform in javascript?


JSP Code:



JavaScript Code:



The formBean and actions are correctly configured in struts-config.xml.

The above code does not update the actionform.

Thanks
James

David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Have you verified you're accessing the DOM element you believe you are?

Also, you're not updating "the ActionForm", you're updating the DOM element. The ActionForm wouldn't be updated until a submission.
James Winfrey
Ranch Hand

Joined: Jan 04, 2009
Posts: 60
Thanks David for your reply.

The DOM element gets updated and the form is submitted using javascript.

But the Changes are not reflected in the ActionForm.

We are using input button of type submit.

James
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

If you are correctly updating the form value via JavaScript, and that form value is being submitted as an empty string, and the form bean doesn't do anything other than take the form value, then it will work. So one of those steps is likely not doing what you think it is.
 
GeeCON Prague 2014
 
subject: Updating actionfrom using javascript