?
Solved

"Submit" pass parameters to 2 diffrent targets

Posted on 2009-07-15
5
Medium Priority
?
198 Views
Last Modified: 2013-11-19
Hello,

I have an HTML page with form on it. Form includes: text fields and 2 buttons.
If I click on button1 -> Another page2.html opens with form on it. And page2.html should get parameters from form1.
If I click on button2 -> I want to submit all the parameters from page1 to my server.
My question: how to define form action: should it be:
<form method="get" action="http://page2.html"">
or
<form method="get" action="http://167.1.1.7/cgi-bin/start">
Should the action be page2 adress or server adress?

THANKS
Margarit
0
Comment
Question by:margarit
[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
  • 3
  • 2
5 Comments
 
LVL 9

Accepted Solution

by:
xBellox earned 2000 total points
ID: 24859443
Left the action blank, and fill it according to the pressed button.

<script language=javascript>
  function sendIt(actionURL) {
      document.myform.action = actionURL;
      document.myform.submit();
  }
</script>
 
<form name="myForm" method="get" action="">
 
 
<input type=button name="SendToPage2" value="Send To Page2" onClick="sendIt('http://page2.html');">
<input type=button name="SendToServer" value="Send To Server" onClick="sendIt('http://167.1.1.7/cgi-bin/start');">
 
</form>

Open in new window

0
 

Author Comment

by:margarit
ID: 24859569
THANKS for the fast reply!!!!
I will try it now.
0
 

Author Comment

by:margarit
ID: 24859709
Hi,
I am trying it now.
The problem is:
When I click button: "SendToPage2" I need it to submit params to page2 and navigate to page2.html as well.
But when I click button "SendToServer" the navigation is done from cgi file.
Margarit
0
 
LVL 9

Expert Comment

by:xBellox
ID: 24860032
I didn't understand... When you click the buttons now, what is happening? Because it should send you to the corresponding page.

By the way,  the code has a little typo, the name of the form is myForm with uppercase "F", and in function sendIt() I writed myform, with lowercase "f". So, the correct code should be:

<script language=javascript>
  function sendIt(actionURL) {
      document.myForm.action = actionURL;
      document.myForm.submit();
  }
</script>
 
<form name="myForm" method="get" action="">
 
 
<input type=button name="SendToPage2" value="Send To Page2" onClick="sendIt('http://page2.html');">
<input type=button name="SendToServer" value="Send To Server" onClick="sendIt('http://167.1.1.7/cgi-bin/start');">
 
</form>

Open in new window

0
 

Author Comment

by:margarit
ID: 24860075
Hi,
It was my mistake.
It works fine!!! THANKS a lot!!!
Margarit
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

764 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