From: Andrew Koptyaev on
> If I try to document.getElementById("myInput").submit() where
> myInput is input with submit button
> then got document.getElementById("myImput").submit is not a function
>
> what is the solution?

If I try to document.getElementById("myInput").submit() where
myInput is input with submit button
then got document.getElementById("myInput").submit is not a function

fix error but still not working
From: VK on
On Apr 11, 1:10 pm, "Andrew Koptyaev" <haze...(a)gmail.com> wrote:
> If I try to document.getElementById("myInput").submit() where
> myInput is input with submit button
> then got document.getElementById("myInput").submit is not a function

That is because you named or id'ed your submit button "Submit" or
"submit". NEVER ever do it. The best of all: forget that input[submit]
has name or id attribute: unless forced to deal with multiple submit
buttons.

<form action="your.php" onsubmit="validate(this); return false;">
....
<input type="submit">
</form>

function validate(frm) {
// if frm input server-side sync check OK then:
// frm.submit();
//
// On programmatic submit() form onsubmit handler
// is not called
}

Of course AJAX call has to be synced and of course it is very bad is
server-side check may tack a noticeable amount of time: for user it
will be like the browser became frozen on submit click.

To make it really usable you need to break it on blocks and allow
screen refresh, something like:

<form action="your.php" onsubmit="return validate(this);">
....
<input type="submit">
</form>

function validate(frm) {
// show "checking" message
// or any visual signal that something
// is going on but may take time

// release context so the page could be updated:
window.setTimeout(validate2(frm), 10);

return false;
}

function validate2(frm) {
// do AJAX data check
// if frm input server-side sync check OK then:
// frm.submit();
//
// On programmatic submit() form onsubmit handler
// is not called
}

etc.
From: Sean Kinsey on
On Apr 11, 3:15 pm, VK <schools_r...(a)yahoo.com> wrote:
> On Apr 11, 1:10 pm, "Andrew Koptyaev" <haze...(a)gmail.com> wrote:
>
> > If I try to document.getElementById("myInput").submit() where
> > myInput is input with submit button
> > then got document.getElementById("myInput").submit is not a function
>
> That is because you named or id'ed your submit button "Submit" or
> "submit".

I can see nothing to support that statement.
The reason is that the input element has not submit method, only the
form.

> NEVER ever do it. The best of all: forget that input[submit]
> has name or id attribute: unless forced to deal with multiple submit
> buttons.
>
> <form action="your.php" onsubmit="validate(this); return false;">
> ...
>  <input type="submit">
> </form>
>
> function validate(frm) {
>  // if frm input server-side sync check OK then:
>  // frm.submit();
>  //
>  // On programmatic submit() form onsubmit handler
>  // is not called
>
> }
>
> Of course AJAX call has to be synced and of course it is very bad is
> server-side check may tack a noticeable amount of time: for user it
> will be like the browser became frozen on submit click.

There is no reason to use a synchronous call here.

>
> To make it really usable you need to break it on blocks and allow
> screen refresh, something like:
>
> <form action="your.php" onsubmit="return validate(this);">
> ...
>  <input type="submit">
> </form>
>
> function validate(frm) {
>  // show "checking" message
>  // or any visual signal that something
>  // is going on but may take time
>
>  // release context so the page could be updated:
>  window.setTimeout(validate2(frm), 10);

This is an error, its either 'setTimeout("validate2(frm);",10);' which
is bad as it uses eval and thus runs only in the global scope,
or 'setTimeout(function(){validate2(frm);},10)'
Either way, its not needed if you just start an async operation

From: VK on
> > That is because you named or id'ed your submit button "Submit" or
> > "submit".
>
> I can see nothing to support that statement.
> The reason is that the input element has not submit method, only the
> form.

Very true? and that's the point :-) Now try this:

<form action="">
<input type="submit" name="submit" value="Submit">
</form>

and now document.forms[0].submit() or any variants. A very old DHTML
oops, never fixed.


> > NEVER ever do it. The best of all: forget that input[submit]
> > has name or id attribute: unless forced to deal with multiple submit
> > buttons.
>
> > <form action="your.php" onsubmit="validate(this); return false;">
> > ...
> >  <input type="submit">
> > </form>
>
> > function validate(frm) {
> >  // if frm input server-side sync check OK then:
> >  // frm.submit();
> >  //
> >  // On programmatic submit() form onsubmit handler
> >  // is not called
>
> > }
>
> > Of course AJAX call has to be synced and of course it is very bad is
> > server-side check may tack a noticeable amount of time: for user it
> > will be like the browser became frozen on submit click.
>
> There is no reason to use a synchronous call here.

There is a very good one. Otherwise the AJAX check request will be
sent and - right after - the form submitted without waiting check
results.

> > To make it really usable you need to break it on blocks and allow
> > screen refresh, something like:
>
> > <form action="your.php" onsubmit="return validate(this);">
> > ...
> >  <input type="submit">
> > </form>
>
> > function validate(frm) {
> >  // show "checking" message
> >  // or any visual signal that something
> >  // is going on but may take time
>
> >  // release context so the page could be updated:
> >  window.setTimeout(validate2(frm), 10);
>
> This is an error, its either 'setTimeout("validate2(frm);",10);' which
> is bad as it uses eval and thus runs only in the global scope,
> or 'setTimeout(function(){validate2(frm);},10)'
> Either way, its not needed if you just start an async operation

The latter one, right. My typo? thank you for correcting.

From: Sean Kinsey on
On Apr 11, 3:41 pm, VK <schools_r...(a)yahoo.com> wrote:
>
> There is a very good one. Otherwise the AJAX check request will be
> sent and - right after - the form submitted without waiting check
> results.

Nope, the 'return false;' statement will cancel the submit.

<snip>
> The latter one, right. My typo? thank you for correcting.

Whats up with the question mark?