Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Struts and the fly likes javascript and Struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "javascript and Struts" Watch "javascript and Struts" New topic

javascript and Struts

Davide Alagna

Joined: Feb 16, 2005
Posts: 5
Hi everybody,
i'm using struts and writing a javascript function that shows a confirmation message before deleting an element from a collection select:

function deleteElem() {
action = confirm("Delete selected element?");
if (action == true) {
else return;

I don't know how to indicate the action to do in the "if" statement with Struts.
How does Struts handle the formName.submit() = 'doSomething' inside a javascript?

Thanks in advance,
Ray Stojonic
Ranch Hand

Joined: Aug 08, 2003
Posts: 326
If all you need to accomplish is to confirm the user wants to delete an element, the following should suffice:

Alternately, if you have multiple submit buttons on your form and only want this action for a particular button, you can do this:

(on submit and on click should be onsubmit and onclick, the board doesn't like them)
At the end of the day, Struts is handling the server-side, javascript is handling the client-side, and the two never really meet.
[ February 16, 2005: Message edited by: Ray Stojonic ]
I agree. Here's the link:
subject: javascript and Struts
It's not a secret anymore!