?
Solved

Need Forms Example

Posted on 2006-11-01
2
Medium Priority
?
320 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 8

Accepted Solution

by:
mhunts earned 1000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Hey fellow admins! This time, I have a little fairy tale for you. As many tales do, it starts boring and then gets pretty gory. I hope you like it. TL;DR: It is about an important security matter, you should read it if you run or administer Windows …
This month, Experts Exchange’s free Course of the Month is focused on CompTIA IT Fundamentals.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

752 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