473,748 Members | 2,320 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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="RedirectL ogin" method="POST" action="login.p hp">
<input type="hidden" name="LogType" value="ManagePr ofile">
</form><script
language="javas cript">document .forms["RedirectLo gin"].submit();</script>

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

please help

Bob

Jul 23 '05 #1
8 2085
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="RedirectL ogin" method="POST" action="login.p hp">
<input type="hidden" name="LogType" value="ManagePr ofile">
</form><script
language="javas cript">document .forms["RedirectLo gin"].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["RedirectLo gin"].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='documen t.forms["RedirectLo gin"].submit()';">
Jul 23 '05 #3
Hi both,

Thanks for your answers.
Use onLoad event instead.

<body onLoad='documen t.forms["RedirectLo gin"].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='documen t.forms["RedirectLo gin"].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 (whateverYourCo nditionIs) {
print "<body onload=\"docume nt.forms['RedirectLogin'].submit();\">";
} else {
print "<body>";
}
?>

or

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

or

<body>
<!-- content -->
<?php
if (whateverYourCo nditionIs) {
print "<script type=\"text/javascript\">";
print "window.onl oad = function() {";
print "document.f orms['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*****@agrico reunited.com>
comp.lang.javas cript 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='documen t.forms["RedirectLo gin"].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.co m...
Bob Bedford said:

Hi both,

Thanks for your answers.
Use onLoad event instead.

<body onLoad='documen t.forms["RedirectLo gin"].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*****@agrico reunited.com> a écrit dans le message de
news:41******** *******@agricor eunited.com...
Bob Bedford wrote:
Hi both,

Thanks for your answers.
Use onLoad event instead.

<body onLoad='documen t.forms["RedirectLo gin"].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 (whateverYourCo nditionIs) {
print "<body onload=\"docume nt.forms['RedirectLogin'].submit();\">";
} else {
print "<body>";
}
?>

or

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

or

<body>
<!-- content -->
<?php
if (whateverYourCo nditionIs) {
print "<script type=\"text/javascript\">";
print "window.onl oad = function() {";
print "document.f orms['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******@YouKn owWhatToDoHereh otmail.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.p hp

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
7772
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" action="/test.php"> <input type =submit name="add"> form elements but also <a href="#" onClick=document.myForm.submit()>edit</a>
2
5333
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 currently working on is supposed to be HTML 4 (w3c) complient, but according to the HTML validator the name attribute has been depreciated and should no longer be used. I'm not saying I agree with this, just that I have little choice in the matter....
13
40755
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 style="display:none"> can be displayed by setting the style attribute to "display:", or hidden with "display:none". This gives the illusion that the person filling out the form is switching from page to page...without the overhead of extra hits on the server,...
7
2991
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 that will check the value of the imput tag to make sure it ends with .jpg, .jpeg. this works fine on the jubmit button using onclick="myHandler(this)"
1
3793
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 HTML form to. the actual form-parsing page resides on a server that's uneditable to me since it sits on an inaccessible server. my problem is more irritating than anything; everything double-submits.. when you submit the form, I've forced a...
7
4892
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 because then it didn't work in IE. How can I enable this javascipt form validation to work in Netscape? When I use netscape, none of the alert boxes appear. It submits the form without validating anything.
14
14180
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 src="images/members.gif" alt="Back to members page" name="members" width="270" height="25" border="0"></a> I get the error "document.buysell" is null or not an object, but my form name is buysell and when using the submit button, which is not
5
1722
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
3317
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 works fine. But on Netscape or Mozzilla browsers, the form would simply not submit when the browser is closed.
2
1657
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 message will popup and the cotent of the form should NOT be submitted. (The actual code connects to the database at the backend so I can check if the value is submmited).
0
8822
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9528
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9310
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8235
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6792
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4863
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3298
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2774
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2206
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.