Submit FORM from function 
Author Message
 Submit FORM from function

Hi all,

  I want to submit a FORM from a JS function. The next funtion executes
Ok on IE 5.5 but not on IE 5.0. Also it works fine on Netscape.

function goDocumentos()
{
  alert('goDocumentos');
  document.forms[0].action="my_correct_URL";
  document.forms[0].submit();

Quote:
}

  What happens? Any idea would be appreciated.
  Thanks a lot.

     Jose R.

Sent via Deja.com
http://www.*-*-*.com/



Tue, 10 Jun 2003 21:13:40 GMT  
 Submit FORM from function
We need to see more context, where you call the function etc

Quote:

> Hi all,

>   I want to submit a FORM from a JS function. The next funtion executes
> Ok on IE 5.5 but not on IE 5.0. Also it works fine on Netscape.

> function goDocumentos()
> {
>   alert('goDocumentos');
>   document.forms[0].action="my_correct_URL";
>   document.forms[0].submit();
> }

>   What happens? Any idea would be appreciated.
>   Thanks a lot.

>      Jose R.

> Sent via Deja.com
> http://www.deja.com/

--

        Martin Honnen
        http://javascript.faqts.com/
        http://home.t-online.de/home/martin.honnen/jsgoddies.html



Wed, 11 Jun 2003 01:06:33 GMT  
 Submit FORM from function
Dear Martin:

The function (and the call) is in a HTML page:

<html>
<head>
  <meta http-equiv="expires" content="0">
  <meta http-equiv="Pragma" content="no-cache">
  <meta http-equiv="content-type"
content="text/html;charset=iso-8859-1">
  <title>My Title</title>
  <script>
  <!--
     var ValorActivo;

     function goDocumentos()
     {
        alert('goDocumentos');
        document.forms[0].action="my_correct_URL";
        document.forms[0].submit();
     }
  // -->
  </script>
</head>
<body>
...
<A HREF="#"  onClick="goDocumentos();">
<IMG NAME="button1" BORDER="0" Alt="Document
List" SRC="/PathImage/image2.gif" ALIGN=TOP></A>
...
</body>
</html>



Quote:
> We need to see more context, where you call the
function etc
> --

>    Martin Honnen
>    http://javascript.faqts.com/
>    http://home.t-

online.de/home/martin.honnen/jsgoddies.html

Sent via Deja.com
http://www.deja.com/



Sun, 15 Jun 2003 16:58:58 GMT  
 Submit FORM from function
Here is my explanation:

The HREF attribute of the A Element leads
to the same page. It must interfere with the
Submit Method of the Form. You must avoid
the ONCLICK HTML event on the A Element,
and move the ONCLICK contents into the
HREF, as I did in my version below

<!--*****************************************-->

<A HREF="javascript: goDocumentos();">
<IMG NAME="button1" BORDER="0" Alt="Document
List" SRC="/PathImage/image2.gif" ALIGN=TOP></A>

<!--*****************************************-->

Anyway, ONCLICK events should be avoided on A Elements.
Also, HREF="#" in A Elements should be replaced by
HREF="javascript: void(0)".

The former does some kind of bastardized ''reload'' which can
interfere with other events, while the later does *nothing*.

Raoul



Mon, 23 Jun 2003 01:29:04 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Function Form Submit

2. problem submitting form from a function

3. submitting a form inside a function ?

4. Function won't run on form submit?

5. SUBMIT form with 3 different submit buttons - error

6. form submits hrefs images and submit buttons

7. Submitting Form WITHOUT Submit Button

8. Form wont submit using javascript:submit()

9. form submit using different submit buttons

10. Submitting form without submit button...

11. What fires the submit action of a form without a submit button

12. Submitting Form WITHOUT a Submit Button

 

 
Powered by phpBB® Forum Software