Solved

"Submit" pass parameters to 2 diffrent targets

Posted on 2009-07-15
5
193 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Scrolling the scrollbar in a list in html 9 48
File download script VBSCRIPT fail on download PPT files 2 33
Split in Javascript 5 30
Bad <form> statement? 9 24
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
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).

912 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now