Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

"Submit" pass parameters to 2 diffrent targets

Posted on 2009-07-15
5
Medium Priority
?
199 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

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

Find out what you should include to make the best professional email signature for your organization.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

610 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