Connecting Tech Pros Worldwide Forums | Help | Site Map

Problem on FIREFOX with "document.form.submit();"

Alex
Guest
 
Posts: n/a
#1: Jul 23 '05
Hello,

I use the following script inside a page. My page contains : 1 FORM,
Some Hidden fields, and one line of JAVASCRIPT in order to instantly
post the Form.
The problem is that under FIREFOX, the JAVASCRIPT line don't seems to
be correct, because FIREFOX does'nt post the Form... But my javascript
line looks correct to me...

Below is the Script; thanks for your Help in advance.
Alex.

<form action="my_next_page.html" method="POST" name="form1">
<input type="hidden" name="hidden_field1" size="40"
value="some_value1">
<input type="hidden" name="hidden_field2" size="40"
value="some_value2">
</form>
<!--The following Javascript line doesn't work, but why ?-->
<script language="JavaScript">window.document.form1.submit ();</script>

Thanks... :-)

RobB
Guest
 
Posts: n/a
#2: Jul 23 '05

re: Problem on FIREFOX with "document.form.submit();"


Alex wrote:[color=blue]
> Hello,
>
> I use the following script inside a page. My page contains : 1 FORM,
> Some Hidden fields, and one line of JAVASCRIPT in order to instantly
> post the Form.
> The problem is that under FIREFOX, the JAVASCRIPT line don't seems to
> be correct, because FIREFOX does'nt post the Form... But my[/color]
javascript[color=blue]
> line looks correct to me...
>
> Below is the Script; thanks for your Help in advance.
> Alex.
>
> <form action="my_next_page.html" method="POST" name="form1">
> <input type="hidden" name="hidden_field1" size="40"
> value="some_value1">
> <input type="hidden" name="hidden_field2" size="40"
> value="some_value2">
> </form>
> <!--The following Javascript line doesn't work, but why ?-->
> <script[/color]
language="JavaScript">window.document.form1.submit ();</script>[color=blue]
>
> Thanks... :-)[/color]

Who knows, could be the usual timing error. Try onload instead:

<html>
<head>
<script type="text/javascript">

window.onload = function()
{
document.forms[0].submit();
}

</script>
</head>
<body>
..........
..........

micha
Guest
 
Posts: n/a
#3: Jul 23 '05

re: Problem on FIREFOX with "document.form.submit();"


as far i can see you just want to pass two values that cannot be
altered by the user to the next page. why use a form at all?

some kind of redirect to "my_next_page.htm?value1=value&value2=value"
will make the values accessible like posted with method="get" and you
can avoid javascript at all (which is always desirable - imho)

micha

Closed Thread