Solved

"Submit" pass parameters to 2 diffrent targets

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

746 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

10 Experts available now in Live!

Get 1:1 Help Now