Solved

Need Forms Example

Posted on 2006-11-01
2
277 Views
Last Modified: 2010-04-01
I have  a form that needs multiple buttons.  So far, I've been using one button for <submit>

  if button A is pushed then:  <input type="hidden" name="myVar" value="valueA">
  if button B is pushed then:  <input type="hidden" name="myVar" value="valueA">

<form action="/myAction">

     <html:submit property="action">SUBMIT</html:submit>

</form>

It needs to look like I have 2 submit buttons.  How do I do this?
0
Comment
Question by:tmonteit
2 Comments
 
LVL 8

Accepted Solution

by:
mhunts earned 500 total points
ID: 17851474
You second button should set "valueB" not "valueA" I suppose.

Write two Javascript functions, one for each return value. Each function would set the appropriate return value.

For your first submit button, invoke the first Javascript. For the second submit button, invoke the second Javascript.
0
 

Author Comment

by:tmonteit
ID: 17851646

WOW!  I need some real help then.  Appologies for my frustration.  My post is a result of abandoning that type of solution.

I had tried something like that.  (code below)  It does JACK.    I can't debug it.  I can't make it print anything anywhere!!?? to see why the heck it won't work.    

I was hoping I might be able to do some simple tag-like solution.

If you can help with this one, I would be VERY thankful.

------------BEGIN WEB PAGE ----------
<script language="JavaScript" type="text/javascript" src="common.js"></script>

<input type="button" value="<bean:message key="common.save"/>" onclick="doPost(document.trainingHistoryForm, 'trainingHistory.do', 'save', null, null, null);">
------------END WEB PAGE ----------

------------BEGIN common.js ----------
function doPost(form, action, dispatch, param1, value1, anchor) {

      // Get the form action url
      var url = constructURL(action, dispatch, param1, value1, anchor);

      // Set it on the form and submit
      System.out.println("CommonJsp_1: url=" + url);
      document.write("CommonJsp_2: url=" + url);
      out.println("CommonJsp_3: url=" + url);
      
      form.action = url;
      form.submit();

}

function constructURL(action, dispatch, param1, value1, anchor) {

      var url = action;
      var nextSeperator = '?';
      if (dispatch != null) {
            url += (nextSeperator + 'dispatch=' + escape(dispatch));
            nextSeperator = '&';
      }
      if (param1 != null) {
            url += (nextSeperator + escape(param1) + '=' + escape(value1));
      }
      if (anchor != null) {
            url += '#' + escape(anchor);
      }
      return url;

}

------------END COMMON common.js ----------
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Learn to move / copy / export exchange contacts to iPhone without using any software. Also see the issues in configuration of exchange with iPhone to migrate contacts.
In this article, you will read about the trends across the human resources departments for the upcoming year. Some of them include improving employee experience, adopting new technologies, using HR software to its full extent, and integrating artifi…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now