You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Wendy Smoak <We...@asu.edu> on 2002/10/16 19:39:20 UTC

html:submit with an onclick

I need to set two form properties when a button is clicked.  The following
works with just the setAction() call, but if I add the setKeyToDelete(), it
doesn't.  I don't know much about Javascript, though, so I may have this all
wrong.

The docs have [RTExpr] with the onclick attribute, so I was hoping it would
evaluate before calling the function.  But it doesn't even compile as is.
(Then again, I'm looking at the nightly build docs, but using 1.1.  Has the
RTExpr functionality been added recently?)

<html:submit property="submit" 
              onclick="setAction('Delete Staff');
setKeyToDelete('<bean:write name="staffMember"/>');"
           styleClass="deleteButton" titleKey="button.delete.staff" 
               value="     "/>

The problem I'm trying to solve:

12345 [x]
23432 [x]
23433 [x]

User clicks one of the delete buttons.  The [x] buttons cannot have a
'value' attribute because no text can show up on the button-- it's an image.
I don't know how many buttons there will be in advance, and I have to figure
out which button was pressed.

There *is* a List in the ActionForm.  It has the [12345,23423,23433] values
noted above.  I've read about the List-backed form attributes, but I don't
quite see how to use it to solve this problem.

There is a LookupDispatchAction that looks at the 'action' form element, so
I have to get that set, as well as set something that will allow me to
figure out which of the values the person is trying to delete.

-- 
Wendy Smoak
Applications Systems Analyst, Sr.
Arizona State University PA Information Resources Management