Re forms

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

having some problems with forms. under xhtml strict, a simple form to
open an ftp session, seems to work under Mozilla but not IE 6a ny clues,
and passes no tests, full location on my machine,

question do you have to use the name attribute when using javascript, I
thought it was going to be depreciated? /

It seems to work under Moz.. but IE shows a blank page


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
" ">
<html xmlns=" " xml:lang="en" lang="en">
  <title>VPub Home Page</title>
<snip...  .................... meta info.>
  <link rel="stylesheet" type="text/css" href="/style/style.css" />
  <link rel="stylesheet" type="text/css" href="/style/forms.css" />
  <script type="text/javascript" src="/style/logon.js" />
<p>Hi  <snip...>  ftp</p>
<h1> Welcome to Vpub ftp logon</h1>
<h2>Login to Local Ftp Server</h2>

<form id="ftplogs" name="ftplogs" action="javascript:loadFtp()">
<legend> log in details to</legend>
<label for="ftpuser">
User Id
                    <input id="ftpuser" name="ftpuser" type="text"
value="" />
<label for="pssword">
                    Pass word
                    <input id="pssword" name="pssword" type="password"
value="" />
<input class="submit" type="submit" value="Login" />

Re: Re forms

Hi again, hate to reply to myself but...

I think I am making progress, by removing the name attribute it now
passes w3, but I am having problems still getting the form value
var passwrd=document.getElementById("ftplogs:pssword");
this returns a null string

any suggestions

adrian suri wrote:
Quoted text here. Click to load it

Re: Re forms

adrian suri wrote:
Ok got it working in Moz and validatting
changing to this format
var user=document.getElementById("ftpuser").value;

but I still get a blamk page in IE

Quoted text here. Click to load it

Re: Re forms

On 02/10/2005 13:54, adrian suri wrote:


Quoted text here. Click to load it

No, though obsolete browsers like NN4 will not utilise id attributes
properly. They don't implement the document.getElementById method, anyway.

You should test for methods before using them:

   var user, password;

   if(document.getElementById) {
     user     = document.getElementById('ftpuser');
     password = document.getElementById('pssword');

     if(user && password) {
       /* Use user.value and password.value */

See below, though.

Quoted text here. Click to load it

The name attribute was designated for backwards-compatibility only on
many elements a long time ago. It acted as a unique identifier;
precisely the purpose of the id attribute. It hasn't been formally
deprecated, though it only applies to certain elements under XHTML
Strict (though it is still present in HTML Strict).


Quoted text here. Click to load it

Do not use element minimisation with elements that do not have an EMPTY
content model. This is clearly stated in the Appendix C compatibility
guidelines of XHTML 1.0, and the route of your problems with IE.

Quoted text here. Click to load it

Neither the id nor the name attributes are necessary, and your site
should not depend on scripting:

   function loadFTP(form) {
     var elem = form.elements,
         user = elem.ftpuser.value,
         pass = elem.pssword.value;

     if(user && pass) {
       location.href = 'ftp://' + user + ':' + pass + '';
     } else {
       alert('Please enter your user name and password.');

   <form action="redirect" onsubmit="loadFTP(this); return false;">

where 'redirect' is a server-side resource that will perform the
redirection in place of the client-side script should it fail to execute.

Using the above, you could remove the id attributes from the INPUT
elements, too.



Michael Winter
Prefix subject with [News] before replying by e-mail.

Re: Re forms

Thanks for pointing out my error, fixed now, the problem is my
javascript book is a bit out of date, so I had to experement a bit with
the include line, it verifies as
<script src="/style/ftp1.js" type="text/javascript"></script>


Michael Winter wrote:
Quoted text here. Click to load it

Site Timeline