Submit Question

M

mtek

Hi,

Another issue. I'm triny to submit a form and have it run some
Javascript validation code before continuing. The button is an HTML
button. This is my code:


a href="javascript:document.Add_Data.action =
'savedata.php';document.Add_Data.submit();">Save Data</a>


The name of the form is Add_Data. My FORM tag looks like this:

<FORM NAME='Add_Data' METHOD=POST onsubmit="return
formvalidation(this)">

Any idea why that would not work??
 
J

Joost Diepenmaat

Hi,

Another issue. I'm triny to submit a form and have it run some
Javascript validation code before continuing. The button is an HTML
button. This is my code:


a href="javascript:document.Add_Data.action =
'savedata.php';document.Add_Data.submit();">Save Data</a>

that's not a button. document.Add_Data is not the form (at least not in
any decent browser).

use document.forms.Add_Data.submit(); instead.
The name of the form is Add_Data. My FORM tag looks like this:

<FORM NAME='Add_Data' METHOD=POST onsubmit="return
formvalidation(this)">

Any idea why that would not work??

http://catb.org/~esr/faqs/smart-questions.html#code
http://catb.org/~esr/faqs/smart-questions.html#bespecific
 
M

mtek

that's not a button. document.Add_Data is not the form (at least not in
any decent browser).

use document.forms.Add_Data.submit(); instead.




http://catb.org/~esr/faqs/smart-que...org/~esr/faqs/smart-questions.html#bespecific


I want to make the botton an HTML button, not the typical form button
you always see. I tried your document.forms.Add_Data.submit() with no
luck. I put a document.write in the function it calls, and it never
even goes into the function....skipps it altogether....
 
M

mtek

that's not a button. document.Add_Data is not the form (at least not in
any decent browser).

use document.forms.Add_Data.submit(); instead.




http://catb.org/~esr/faqs/smart-que...org/~esr/faqs/smart-questions.html#bespecific


Check out what I found here: http://www.quirksmode.org/js/forms.html

document.forms[0].submit()
Please note that when a form is submitted by JavaScript the onsubmit
event handler is never executed.

So, there must be a way to execute this javascript before the form is
submitted without using the typical FORM button and using HTML....

John.
 
J

Joost Diepenmaat

I want to make the botton an HTML button, not the typical form button
you always see.

I tried your document.forms.Add_Data.submit() with no
luck. I put a document.write in the function it calls, and it never
even goes into the function....skipps it altogether....

Don't use document.write in any code that's not immediately executed
when loaded. It overwrites the current page and will mess up everything.

Use alert() if you've got only one or two debugging messages, or install
firebug on firefox and use console.debug() to log to the javascript
console.
 
J

Joost Diepenmaat

Check out what I found here: http://www.quirksmode.org/js/forms.html

document.forms[0].submit()
Please note that when a form is submitted by JavaScript the onsubmit
event handler is never executed.

So, there must be a way to execute this javascript before the form is
submitted without using the typical FORM button and using HTML....

Yeah. Just call the function yourself.
 

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,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top