473,386 Members | 1,706 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,386 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 4256
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.