submit form data approaches

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I tried to figure out how many approaches to submit form data. Here's my
Please advise. Thanks!!

1) html submit button, most commonly used.

<form name="formName" action="url" method="post">
<input type="submit">

2) html regular button, and a JavaScript to invoke the form.submit() method

<form action="url"
function submitForm()
{ //etc...
<input type="button" onClick="submitForm()">

3) onsubmit event handling
<form name="formName" action="url" method="post" onsubmit="return
function submitForm()
{ //etc...
  //formName.submit(); //NOT NECESSARY!!
<input type="submit">

Re: submit form data approaches

Quoted text here. Click to load it

Or, none of the below.

Typically this is done with three submit buttons, each with the same name
but a different value.

  Have your server script parse which button was used by looking at the
value, and then send the data on it's way.

  If you must use javascript, then do something like this

<form onsubmit="changeAction()">....

function changeAction(){
var form=document.forms[0];

if(form['submit_name'].value == 'action1'){

 You may have to adjust that as I'm not sure if javascript will read the
pushed submit value without some help.


Quoted text here. Click to load it

Site Timeline