Solved

Need Forms Example

Posted on 2006-11-01
2
287 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Lotus Notes – formerly IBM Notes – is an email client application, while IBM Domino (earlier Lotus Domino) is an email server. The client possesses a set of features that are even more advanced as compared to that of Outlook. Likewise, IBM Domino is…
A customer recently asked me about anti-malware and the different deployment options available for his business. Daily news about cyberattacks, zero-day vulnerabilities, and companies that suffered a security breach made him wonder if the endpoint a…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.

911 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