Solved

Need Forms Example

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
servlet concurrency 13 102
iterator example remove 8 74
Is it possible to "sandbox" html content within a JSP? 4 101
how to add new optional parameter to JSP 1 42
There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
In this increasingly digital world, security hacks are no longer just a threat, but a reality. As we've witnessed with Target's big identity hack 2013, Heartbleed in 2015, and now Cloudbleed, companies and their leaders need to prepare for the unthi…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

821 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