Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > submit form data in multiple buttons on a html form

Reply
Thread Tools

submit form data in multiple buttons on a html form

 
 
Matt
Guest
Posts: n/a
 
      06-26-2004
The problem is I have 3 buttons that need to submit the form to different
URL.
My approach is to declare <input type="submit"> rather than <input
type="button">.
And put the following in the JavaScript:
InputForm.action="URL LOCATION"
InputForm.method="POST";

I think we don't need InputForm.submit(); because <input type="submit">.

Please advise and comment my approaches. Thanks!!

==============================================
<html>
<head>
<script type="text/javascript">
function onClickURL1()
{ InputForm.action="url1.asp"
InputForm.method="POST";
//InputForm.submit(); //NOT NECESSARY!! because of input type="submit"??
}
function onClickURL2()
{ InputForm.action="url2.asp"
InputForm.method="POST";
//InputForm.submit(); //NOT NECESSARY!! because of input type="submit"??
}
function onClickURL3()
{ InputForm.action="url3.asp"
InputForm.method="POST";
//InputForm.submit(); //NOT NECESSARY!! because of input type="submit"??
}
</script>
</head>
<body>
<form name="InputForm">
<P><input type="text" name="username">
<P><INPUT type="submit" value="submit form data to URL1" name="action1"
onclick="onClickURL1()">
<P><INPUT type="submit" value="submit form data to URL2" name="action2"
onclick="onClickURL2()">
<P><INPUT type="submit" value="submit form data to URL3" name="action3"
onclick="onClickURL3()">
</form>
</body>
</html>
 
Reply With Quote
 
 
 
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      07-05-2004
Matt wrote:
> The problem is I have 3 buttons that need to submit the form to different
> URL.


Use 3 forms with different "action" attribute values. Use CSS to
format them display:inline to prevent the "form" element from creating
a paragraph.

> My approach is to declare <input type="submit"> rather than <input
> type="button">.


That is not a declaration of anything at all.

> And put the following in the JavaScript:
> InputForm.action="URL LOCATION"
> InputForm.method="POST";


This is proprietary referencing. Use document.forms["InputForm"]...
instead.

> I think we don't need InputForm.submit(); because <input type="submit">.
>
> Please advise and comment my approaches. Thanks!!
>
> ==============================================
> <html>


This document lacks a DOCTYPE declaration prior to the root element and
is thus not Valid HTML. See <http://validator.w3.org/> for details.

> <head>
> <script type="text/javascript">
> function onClickURL1()
> { InputForm.action="url1.asp"
> InputForm.method="POST";
> //InputForm.submit(); //NOT NECESSARY!! because of input type="submit"??
> }


Have you ever thought about users without client-side scripting support?

> [...]
> <form name="InputForm">
> <P><input type="text" name="username">
> <P><INPUT type="submit" value="submit form data to URL1" name="action1"
> onclick="onClickURL1()">


Timing issues are likely to cause this to fail. Use either
type="button" instead or, much better, do not use client-side
scripting at all.


PointedEars
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Forms with multiple submit buttons vs 'form' objects with single 'submit' methods neil.fitzgerald@ic.ac.uk Python 4 04-14-2006 04:58 PM
submit form data in multiple buttons on a form Matt ASP General 2 06-27-2004 11:43 AM
submit form data in multiple buttons on a html form Matt HTML 0 06-26-2004 08:04 PM
Multiple asp:buttons on one form but ONLY one should submit? D. Shane Fowlkes ASP .Net 3 02-24-2004 12:17 PM
Multiple forms and Multiple submit buttons and validation sandyde2 Javascript 2 10-02-2003 09:25 AM



Advertisments