In an intial how-to I tend to simplify things.
<form ...>
...
<input type="submit" value"edit" onclick="return button_onclick( this , '/editaction.do')"/>
<input type="submit" value"Add" onclick="return button_onclick( this , '/addaction.do')"/>
<input type="submit" value"Remove" onclick="return button_onclick( this , '/removeaction.do')"/>
</form>
function button_onclick( oBtn , sAction ) {
var frm = oBtn.form ;
frm.action = sAction;
return true ;
}
Folashade Adeyosoye wrote:
I think with this, you would have multiple JS functions...
-----Original Message-----
From: Jason King [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 23, 2005 4:25 PM
To: Struts Users Mailing List
Subject: Re: html: tag four buttons, one action problem
Another thing you could do is use a js onclick handler to change the <form> element's action.
<input type="submit" onclick="return edit_onclick(this)"> // I'm better at the html/js end so you'll have to figure out how to html:submit this.
function edit_onclick( oBtn ) {
var frm = oBtn.form ; // reference to the html form the submit button is in.
frm.action = "/editaction.do" ; // the stuff in the quotes should probably be replaced by some html: reference to fix the url.
return true;
}
Folashade Adeyosoye wrote:
--I am currently doing the same my project...
here is it...
it involves using javascript to change the buttonAction
1. must have a hidden field buttonAction 2. each (Button) submit button must have a property 3. when you click on the button the JS is involked and the hidden filed buttonAction is set and the form is submitted 4. in your Java class, get the value of the button, if task1, do task1, if task2 do task 2
hope that helps
----------------------------------------- <script language="javaScript"> function DoSomething(button) { document.forms[0].buttonAction.value=button.value; document.forms[0].submit(); } </script>
-----------------------------------------------------
<html:form action="doAnotherThing?action=addAnotherThing" > <html:hidden property="buttonAction"/>
<p>
<html:button property="task1" value="Add Property" onclick="DoSomething(this);"
/>
<html:button property="task2" value="Add Property/Sublease" onclick="DoSomething(this);"
/>
<html:reset>
<bean:message key="button.reset"/>
</html:reset>
<html:cancel/>
<%--
<bean:message key="button.cancel"/>
</html:cancel>
--%>
</p>
</html:form>
---------------------------------------------------------------------------
I cannot do a href_link, I need to submit the form to get the selected value
On Wed, 23 Mar 2005 14:58:56 -0600, Scott Purcell <[EMAIL PROTECTED]> wrote:
Hello, I have a form, lets say that has a select list on it. Under it I have the ability to [edit], [delete], [modify] or [cancel].
Each of these buttons goes to a different <action />
but the form page is set for just one of the actions. And to top this off,
from the form.
said we could just use the javascript (see last link) and then change theWe are using links, but they are css links (See below). One of my guys
action of the form, but I was hoping there was a cleaner way.**
submit, but even if they did submit, I need to change action.Here is the actual page links. They appear to only do a href and not a
feel it is not clean.The last one calls a javascript, changes the action and submits, but I
User</html:link> Is there a cleaner way to handle this.
*****Optimal would be a tag that submits to a certain action:******
<html:link action="/newUser" styleClass="mainLink">New
User</html:link> <html:link action="/editUser" styleClass="mainLink">Edit
User</html:link> <html:link action="/deleteUser" styleClass="mainLink">Delete
styleClass="mainLink">Cancel</html:link><html:link action="/mainAdmin"
Bar</html:link> **<html:link href="javascript:editUser();" styleClass="mainLink">Foo
I am sorry for all questions in this regard, but I could use some help.
Scott
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]