473,320 Members | 1,804 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

form.submit and Netscape.

I've a code with redirect to a login page if nobody is registered. It works
fine on IE6, but I'm trying with NS, and it doesn't work.

Here is the code:

<form name="RedirectLogin" method="POST" action="login.php">
<input type="hidden" name="LogType" value="ManageProfile">
</form><script
language="javascript">document.forms["RedirectLogin"].submit();</script>

I've even tried with 'RedirectLogin', but it doesn't work either.

please help

Bob

Jul 23 '05 #1
8 2050
Bob Bedford wrote:
I've a code with redirect to a login page if nobody is registered. It works
fine on IE6, but I'm trying with NS, and it doesn't work.

Here is the code:

<form name="RedirectLogin" method="POST" action="login.php">
<input type="hidden" name="LogType" value="ManageProfile">
</form><script
language="javascript">document.forms["RedirectLogin"].submit();</script>

I've even tried with 'RedirectLogin', but it doesn't work either.


Use the javascript-console to catch errors like this (Tools / Web Development / JavaScript Console).

You will get the message "Error: document.forms.RedirectLogin has no properties".

That's because you have you javascript-code inline to execute as soon as the browser has reached that point. But no one can guarantee you (and this is what you are seeing) that the part of the page you're refering to is already properly initialized in the browser internals.

Put your code in the onload-Handler, this ensures everything is loaded and that the form is accessible:

<script type="text/javascript">
window.onload = function() {
document.forms["RedirectLogin"].submit();
}
</script>

and remove the inline tag.

HTH
- Markus
Jul 23 '05 #2
VK
Netscape is traditionally slow in rendering forms (the payback for
multi-platform support). It could be that the form object is not initialized
by the moment of the function call, despite it comes after the form tag.

Use onLoad event instead.

<body onLoad='document.forms["RedirectLogin"].submit()';">
Jul 23 '05 #3
Hi both,

Thanks for your answers.
Use onLoad event instead.

<body onLoad='document.forms["RedirectLogin"].submit()';">


The code is generated by a PHP script that "redirect" only on some cases.
It's quite a long work to change things. It's there an other way ?

Bob
Jul 23 '05 #4
Bob Bedford wrote:
Hi both,

Thanks for your answers.
Use onLoad event instead.

<body onLoad='document.forms["RedirectLogin"].submit()';">


The code is generated by a PHP script that "redirect" only on some cases.
It's quite a long work to change things. It's there an other way ?

Bob


How is it "long work" to include the onload event dynamically?

<?php
if (whateverYourConditionIs) {
print "<body onload=\"document.forms['RedirectLogin'].submit();\">";
} else {
print "<body>";
}
?>

or

<?php
print "<body" .
(whateverYourConditionIs ? "
onload=\"document.forms['RedirectLogin'].submit();\"" : "") .
" style=\"margin:1em;\"" .
">";
?>

or

<body>
<!-- content -->
<?php
if (whateverYourConditionIs) {
print "<script type=\"text/javascript\">";
print "window.onload = function() {";
print "document.forms['RedirectLogin'].submit();";
print "}";
print "</script>";
}
?>
</body>

I probably missed several hundred other ways of accomplishing what you want
using PHP. This is what PHP (or any other server-side technology) is for, to
_dynamically_ create content based on certain logic, conditions or data. The
fact that the content PHP is generating is client-side JavaScript is
irrelevant to PHP.

--
Grant Wagner <gw*****@agricoreunited.com>
comp.lang.javascript FAQ - http://jibbering.com/faq

Jul 23 '05 #5
Lee
Bob Bedford said:

Hi both,

Thanks for your answers.
Use onLoad event instead.

<body onLoad='document.forms["RedirectLogin"].submit()';">


The code is generated by a PHP script that "redirect" only on some cases.
It's quite a long work to change things. It's there an other way ?


PHP can redirect to a new page without sending an intermediate
page to the client. Just send them the login page.

Jul 23 '05 #6

"Lee" <RE**************@cox.net> a écrit dans le message de
news:cj********@drn.newsguy.com...
Bob Bedford said:

Hi both,

Thanks for your answers.
Use onLoad event instead.

<body onLoad='document.forms["RedirectLogin"].submit()';">


The code is generated by a PHP script that "redirect" only on some cases.
It's quite a long work to change things. It's there an other way ?


PHP can redirect to a new page without sending an intermediate
page to the client. Just send them the login page.


The problem is that I send user's datas trough POST vars, instead of GET, so
the only way I've found to redirect to some pages with vars in POST, is to
create a FORM with the vars and then submit it. Maybe there is a better way
?

Bob
Jul 23 '05 #7

"Grant Wagner" <gw*****@agricoreunited.com> a écrit dans le message de
news:41***************@agricoreunited.com...
Bob Bedford wrote:
Hi both,

Thanks for your answers.
Use onLoad event instead.

<body onLoad='document.forms["RedirectLogin"].submit()';">
The code is generated by a PHP script that "redirect" only on some cases. It's quite a long work to change things. It's there an other way ?

Bob


How is it "long work" to include the onload event dynamically?

<?php
if (whateverYourConditionIs) {
print "<body onload=\"document.forms['RedirectLogin'].submit();\">";
} else {
print "<body>";
}
?>

or

<?php
print "<body" .
(whateverYourConditionIs ? "
onload=\"document.forms['RedirectLogin'].submit();\"" : "") .
" style=\"margin:1em;\"" .
">";
?>

or

<body>
<!-- content -->
<?php
if (whateverYourConditionIs) {
print "<script type=\"text/javascript\">";
print "window.onload = function() {";
print "document.forms['RedirectLogin'].submit();";
print "}";
print "</script>";
}
?>
</body>

I probably missed several hundred other ways of accomplishing what you

want using PHP. This is what PHP (or any other server-side technology) is for, to _dynamically_ create content based on certain logic, conditions or data. The fact that the content PHP is generating is client-side JavaScript is
irrelevant to PHP.

Javascript can create dynamic <form> tag, as I send POST vars trough my
pages. I want to avoid to show various datas from my site, so for
redirecting, I've to create <form method="post"> and then submit it. If you
have a better way to redirect with post vars, please let me know.

Cheers.

Bob
Jul 23 '05 #8
On Tue, 5 Oct 2004 16:46:55 +0200, Bob Bedford
<be******@YouKnowWhatToDoHerehotmail.com> wrote:

[snip]
Javascript can create dynamic <form> tag, as I send POST vars trough my
pages. I want to avoid to show various datas from my site, so for
redirecting, I've to create <form method="post"> and then submit it. If
you have a better way to redirect with post vars, please let me know.


A PHP group would be a better place to ask:

comp.lang.php
alt.comp.lang.php

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Marc | last post by:
Hello, I have a self - submitting form with multiple submits and I want to detect after the submit which button is pressed. Code example: <form name="example" method="post"...
2
by: Alexander Ross | last post by:
I know that <a href="javascript:document.formname.submit();"> works for this, but can you use a hyperlink to submit a form WITHOUT assigning the form tags name attribute a value. The site I am...
13
by: Dan R Brown | last post by:
I have a large form that is generated dynamically in a jsp using xml / xslt. So, to break up this form into several "tabbed" sections, I break up the form using <div> tags. Each <div...
7
by: greg brant | last post by:
i have a form made up of 2 file inputs and a submit button.. the imputs are to upload images, namley jpeg's for a e-greatings thing im working on. this only works with jpegs so i have a script...
1
by: Display Name | last post by:
the customer I'm developing a site for uses a canned form-parsing page that allows her to have an email subscription opt-in page add emails to a list she can manage using a link that you point your...
7
by: AnnMarie | last post by:
My JavaScript Form Validation doesn't work at all in Netscape, but it works fine in IE. I made some of the suggested changes which enabled it to work in IE. I couldn't make all the changes...
14
by: Chris | last post by:
Heres my problem: <a href="javascript:void(document.buysell.submit())" target="_parent" onMouseOver="MM_swapImage('members','','images/membersf2.gif',1)" onMouseOut="MM_swapImgRestore()"><img...
5
by: ddt_rock | last post by:
Hello, everyone! I have a problem with Netscape. I want to submit form from <A> tag <form name="f1" method="post" action="TTT.htm"> <a href="javascript:document.f1.submit();"> Test </a>
4
by: Yashwant | last post by:
Dear Netscape/Javascript/Java gurus, I am trying to submit a form onUnLoad when the user accidentally closes the browser before clicking on a link to complete the transaction. On IE, this...
2
by: lmeng | last post by:
Hi, I am new to this Forum. Thanks in advance for any kind help. In the following HTML code, when I change the value of one text field then click "Modify" button, if the validation fails a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.