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);"
>    />
>               &nbsp;&nbsp;&nbsp;
>         <html:button 
>      property="task2" 
>      value="Add Property/Sublease"  
>      onclick="DoSomething(this);"
>    />
>               &nbsp;&nbsp;&nbsp;
>    <html:reset>
>      <bean:message key="button.reset"/>
>    </html:reset>
>    &nbsp;&nbsp;&nbsp;
>    <html:cancel/>
>    <%--
>      <bean:message key="button.cancel"/>
>    </html:cancel>
>    --%>
>       </p>
></html:form>
>
>---------------------------------------------------------------------------
--
>
>
>
>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,
I cannot do a href_link, I need to submit the form to get the selected value
from the form.
>>
>>We are using links, but they are css links (See below). One of my guys
said we could just use the javascript (see last link) and then change the
action of the form, but I was hoping there was a cleaner way.**
>>
>>Here is the actual page links.  They appear to only do a href and not a
submit, but even if they did submit, I need to change action.
>> The last one calls a javascript, changes the action and submits, but I
feel it is not clean.
>>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>&nbsp;&nbsp;&nbsp;&nbsp;
>>    <html:link action="/editUser"  styleClass="mainLink">Edit
User</html:link>&nbsp;&nbsp;&nbsp;&nbsp;
>>    <html:link action="/deleteUser" styleClass="mainLink">Delete
User</html:link>&nbsp;&nbsp;&nbsp;&nbsp;
>>    <html:link action="/mainAdmin"
styleClass="mainLink">Cancel</html:link>
>>    <html:link href="javascript:editUser();" styleClass="mainLink">Foo
Bar</html:link>&nbsp;&nbsp;&nbsp;&nbsp;**
>>
>>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]

Reply via email to