473,320 Members | 1,810 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

multiple form destinations

Hello,

I was wondering if it is possible to create in one form 2 destination for
example

<form method="post" action="test.html">
<textarea name="content">
Test
</textarea>
<inbut button="submit" name="submit" value="submit">
</form>

Now I want a second button lets say submit2 and when it is clicked I want to
post to test2.html instead test.html.
Is that possible without an if else?

Thanks for advice
Chris
Jul 20 '05 #1
3 4255
gokul wrote on 28 Nov 2003:
Yes you can do that.
Please follow the steps as follows:
Lets assume form name is myForm
function onSubmit_activat(sURL)
{
document.myForm.action=sURL;
document.myForm.submit();
You should use the forms and elements collections to make the script
compatible with more browsers:

document.forms['myForm'].elements['action'] = sURL;
document.forms['myForm'].submit();
}
<form method="post" name="myForm" >
You shouldn't omit the action attribute, even if you can guarantee
that the user will have JavaScript enabled - it's invalid HTML. If
you can't guarantee that JavaScript will be enabled, you shouldn't
really attempt this method at all, but instead find another way of
presenting your website.
<textarea name="content">
Test
</textarea>
<input type="button" name="submit" value="submit"
onClick="javascript:onSubmit_activat('test.html')" >


At the present moment, your script will probably fail here. The name
of the control is submit, which is also a Form method. Some browsers
will get confused by this. Never name a submit button, submit, or a
reset button, reset. In fact, don't use any names that could collide
with those used by the Form object (lookup the properties and methods
of the Form object in a JavaScript reference).

Furthermore, if you write valid HTML, there should never be a need to
use the JavaScript protocol specifier (it's only supposed to be used
in URIs anyway, which again is discouraged). Specify the language of
intrinsic events with the following META element (placed in the
document HEAD):

<META http-equiv="Content-Script-Type" content="text/javascript">

<snipped other control and original post>

Mike

And please don't top-post. :)

--
Michael Winter
M.******@blueyonder.co.uk.invalid (remove ".invalid" to reply)
Jul 20 '05 #2
Michael Winter wrote:
gokul wrote on 28 Nov 2003:
Yes you can do that.
Please follow the steps as follows:
Lets assume form name is myForm
function onSubmit_activat(sURL)
{
document.myForm.action=sURL;
document.myForm.submit();


You should use the forms and elements collections to make the script
compatible with more browsers:

document.forms['myForm'].elements['action'] = sURL;


action isn't an element of the form, it's a property or attribute (<form
.... action="somepage.cgi" ...>), so the code originally provided is
correct.

--
| Grant Wagner <gw*****@agricoreunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
* http://www.mozilla.org/docs/web-deve...upgrade_2.html
Jul 20 '05 #3
Grant Wagner wrote on 02 Dec 2003:
Michael Winter wrote:
gokul wrote on 28 Nov 2003:
> Yes you can do that.
> Please follow the steps as follows:
> Lets assume form name is myForm
> function onSubmit_activat(sURL)
> {
> document.myForm.action=sURL;
> document.myForm.submit();


You should use the forms and elements collections to make the
script compatible with more browsers:

document.forms['myForm'].elements['action'] = sURL;


action isn't an element of the form, it's a property or
attribute (<form ... action="somepage.cgi" ...>), so the code
originally provided is correct.


Sorry, I was thinking for some reason that it was a control in the
OP's form. I know it's an attribute, I think I just blindly altered
it to the collection syntax.

Mike

--
Michael Winter
M.******@blueyonder.co.uk.invalid (remove ".invalid" to reply)
Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: Claudio Grondi | last post by:
I would like to save time copying the same file (>6 GByte) to various different target storage media connected to the system via USB. Is there a (Python or other) tool able to help me to do...
3
by: M2 | last post by:
Hi, a have a single form whose elements reside in a table. I want to present a "Submit" and "Cancel" button at the bottom each of which have a different destination. This is of course easy to do...
4
by: LD | last post by:
Is there a way in Access to store more than one value in a field that has been selected from a combo box? For example, if a combo box had three values that you can select, "One", "Two", and...
0
by: i_have_control | last post by:
I'd be grateful for any input on this one: I have three web domains. The destinations of two are set to folders on the first, though that fact is transparent to the user (i.e: it does not...
2
by: John | last post by:
I'm newbie. Just wonder, after googling for several hours: is it impossible to make a login script for, say, three different users and, after successfull login with username and password, redirect...
8
by: aleksandar.ristovski | last post by:
Hello all, I have been thinking about a possible extension to C/C++ syntax. The current syntax allows declaring a function that returns a value: int foo(); however, if I were to return...
8
by: jonathan184 | last post by:
Hi I am trying to copyfiles and dirs keeping there permissions intact and copy to multiple destinations which are on a data.txt file on the txt file i put test1 test2 So where ami going wrong?...
6
by: c h e r r y | last post by:
Hi! I have this code that only submit to checklogin.php I've tried interchanging the destinations for the submit and i always end up having the data only at the last argument. Please help me. ...
3
by: modernshoggoth | last post by:
G'day all, I'm trying to update a single table (containing plans for flights) with information from the same and other tables (containing info for organisations and locations). tblFlightPlans...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.