Solved

"Submit" pass parameters to 2 diffrent targets

Posted on 2009-07-15
5
196 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
  • 3
  • 2
5 Comments
 
LVL 9

Accepted Solution

by:
xBellox earned 500 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

Independent Software Vendors: 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

Suggested Solutions

Title # Comments Views Activity
Technology Resume 7 69
message Alert on an empty search 10 29
I'm a Human captcha checkbox 13 43
Telerik RadEditor Control Save 8 15
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

726 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