Two targets of one form

A

Anita Meyer

Hello,

is it possible to create a form with two submit-buttons which sends the
collected data to two different targets according to the selected button.

When I use two forms I don't have the same data, so this is no option.
 
T

Toby A Inkster

Anita said:
is it possible to create a form with two submit-buttons which sends the
collected data to two different targets according to the selected button.

No. Why do you need to?
 
K

Karl Groves

Anita Meyer said:
Hello,

is it possible to create a form with two submit-buttons which sends the
collected data to two different targets according to the selected button.

When I use two forms I don't have the same data, so this is no option.

This same question has been asked 3 times this week alone.
Please respect the regulars in this group by searching its archives first.

-Karl
 
A

Anita Meyer

Karl said:
This same question has been asked 3 times this week alone.
Please respect the regulars in this group by searching its archives first.

-Karl

Why is it so fascinating for so many people to write an answer like this.
When I search something in the google groups I am often glad to find
threads with more than one entry, but the answer is often "search in the
google groups" - so I would ask you not to write anything if you don't want
to help.

BTW: I cannot find one entry this month which solves the problem.

Greetings
 
K

Karl Groves

A

Anita Meyer

Toby said:
No. Why do you need to?
It is not extremly important, but I would like to save the input into a
html-page on the server, to be able to send it to a sytax-checker which
only can manage urls.

When I click to the check-button - the input should be checked (in a new
window), when I click to the submit-button - the input should be submitted
without check.


I think, it might be possible using javascript to change the target (and
action) on the mousover-event of the check-button and restore the original
target with the mouseout-event. I have not yet tried it, but I think it
should work.

eg:

<form method="post" id="checkandsubmit" action="./submit.php"
enctype="multipart/form-data" target="_self">

should be changed in

<form method="post" id="checkandsubmit" action="./syntaxcheck.php"
enctype="multipart/form-data" target="_blank">

when the mouseover-event is triggered.

Greetings
 
A

Anita Meyer

Karl said:
I would ask you not to post your question if you haven't first sought out
the answer

I think that most people search before asking (me too), since it is faster,
but often you don't find an answer (or just answers like yours - or did you
never search in google groups to find five times the good advice to take a
look at google groups, but not an answer? If not - you should be glad!).
Here's what 30 seconds at google groups found me: at least one discussion
that is probably relevant
(watch the wrap)
http://groups.google.com/[email protected]&rnum=17

I need the opposite of this.

Here's another
http://groups.google.com/groups?hl=...%24kjt%241%40ngspool-d02.news.aol.com&rnum=24

This one is much better and I never would have read it (it is a thread with
only one entry). Thank you for trying to help me.
Should I continue?

please

Greetings
 
T

Toby A Inkster

Anita said:
It is not extremly important, but I would like to save the input into a
html-page on the server, to be able to send it to a sytax-checker which
only can manage urls.

When I click to the check-button - the input should be checked (in a new
window), when I click to the submit-button - the input should be submitted
without check.

Then what you need is something like this:

<form action="myhandler.php" method="get">
<input id="blah" name="blah" type="text">
<input type="submit" name="submit" value="Check"
onclick="window.open('myhandler.php?blah='+document.getElementById('blah').value);return false;">
<input type="submit" name="submit" value="Submit">
</form>

and in the handler:

<?php
if ($_GET['submit'] == 'Check') {
// do stuff to check
} else {
// do stuff to submit
}
?>
 
M

Mark Parnell

When I click to the check-button - the input should be checked (in a new
window),

Only if the user _wants_ it in a new window.
when I click to the submit-button - the input should be submitted
without check.

So have one submit button, with 2 radio buttons - "check" and "send".
Get your script to either check or send the data depending on which
radio button is selected. I used a similar method myself just recently.
I think, it might be possible using javascript to change the target (and
action) on the mousover-event of the check-button and restore the original
target with the mouseout-event. I have not yet tried it, but I think it
should work.

"Work" as in, possibly, perhaps, maybe do what you want in _some_ cases?
Yes.

IOW, Javascript is optional and therefore cannot be relied on.
 
A

Anita Meyer

Toby said:
<form action="myhandler.php" method="get">
<input id="blah" name="blah" type="text">
<input type="submit" name="submit" value="Check"
onclick="window.open('myhandler.php?blah='+document.getElementById('blah').value);return
false;"> <input type="submit" name="submit" value="Submit">
</form>

and in the handler:

<?php
if ($_GET['submit'] == 'Check') {
// do stuff to check
} else {
// do stuff to submit
}
?>

I think this is a very interesting solution, but I am not happy with the
$_GET-part, since there could be much data to transmit and $_POST is better
in this case. But when I find a similar solution which that uses $_POST I
will make it like this.

Thank you very much.

Greetings
 
T

Toby A Inkster

Anita said:
I think this is a very interesting solution, but I am not happy with the
$_GET-part, since there could be much data to transmit and $_POST is better
in this case. But when I find a similar solution which that uses $_POST I
will make it like this.

You will find things difficult with POST. GET makes things easy because
the Javascript can simply open a new window and construct the URL.
 
C

Chris

This same question has been asked 3 times this week alone.
Please respect the regulars in this group by searching its archives first.

-Karl

The evil Karl strikes again.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top