Login form using JavaScript and XML

This is a discussion on "Login form using JavaScript and XML" within the JavaScript Forum section. This forum, and the thread "Login form using JavaScript and XML are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Mar 31st, 2008, 17:30
New Member
Join Date: Mar 2008
Location: Seattle
Age: 26
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Login form using JavaScript and XML

Hi guys!
I'm studying Java.
I have an project that make a login using JavaScript and XML.
That means, file XML contains username and password.
Here is the file that i have created:

PHP: Select all

<script language="javascript">

function 
login()
   {
      if (
document.frmlogin.login_username.value == ""
      {
        
alert("User name is not blank");
        return;
    }
    else if(
document.frmlogin.login_pass.value == "")
    {
        
alert("Password is not blank");
        return;
    }

    else
    {
        var 
xmlDoc= new ActiveXObject("Msxml2.DomDocument.4.0");
        
xmlDoc.load("xml/user.xml");
        var 
ktra=true;
        for(var 
i=0;i<2;i++)
        {
        var 
xml=xmlDoc.childNodes(1).childNodes(1).childNodes(i);
        var 
name=xml.childNodes(0);
        var 
pass=xml.childNodes(1);
if(
name.text==frmlogin.login_username.value &&pass.text==frmlogin.login_pass.value)
    {
        
ktra=true;
        break;
    }
    else
    {
        
ktra=false;
    }
      }
    if(
ktra==true)
    {
        
alert("Login Successfully !!!");
        
window.location="indexAdmin.htm";
    }
    else
    {
        
alert("Login Failed !!!");
    }
    }
    }
</script>
</head>

<BODY onload=login()>
<!--top-->
<CENTER><A HREF="index.htm" TARGET="_self"><img src="images/logo.gif"></A></CENTER>
<TABLE WIDTH="828" BORDER="0" CLASS="navigation" ALIGN="CENTER" bgcolor="#000000">
  <TR> 
    <TD WIDTH="820" vALIGN="top" nowrap>
    <TABLE>
        <TR><CENTER>
            <TD WIDTH="159" ALIGN="CENTER">
                <DIV CLASS="transOFF" onmouseover="this.className='transON'"                                 onmouseout="this.className='transOFF'" ALIGN="bottom">
                -.<A HREF="products.htm" TARGET="_self">PRODUCTS</A>.-
                </DIV>
            </TD>

            <TD WIDTH="159" ALIGN="CENTER">
                <DIV CLASS="transOFF" onmouseover="this.className='transON'"                                 onmouseout="this.className='transOFF'" ALIGN="bottom">
                -.<A HREF="technic.htm" TARGET="_self">TECHICAL SUPPORT</A>.-
            </DIV>
            </TD>

            <TD WIDTH="159" ALIGN="CENTER">
                <DIV CLASS="transOFF" onmouseover="this.className='transON'"                                 onmouseout="this.className='transOFF'" ALIGN="bottom">
                -.<A HREF="admin.htm" TARGET="_self">STAFF LOGIN</A>.-
                </DIV>
            </TD>

            <TD WIDTH="159" ALIGN="CENTER">
                <DIV CLASS="transOFF" onmouseover="this.className='transON'"                                 onmouseout="this.className='transOFF'" ALIGN="bottom">-.
                <A HREF="downloads.htm" TARGET="_self">DOWNLOAD DRIVERS</A>.-
                </DIV>
            </TD>

            <TD WIDTH="159" ALIGN="CENTER">
                <DIV CLASS="transOFF" onmouseover="this.className='transON'"                                 onmouseout="this.className='transOFF'" ALIGN="bottom">-.
                <A HREF="contacts.htm" TARGET="_self">CONTACT US</A>.-
                </DIV>
            </TD>
            </CENTER>
        </TR>
    </TABLE>
     </TD>
  </TR>
</TABLE>
<!--top-->
<!--main-->
<TABLE WIDTH="828" BORDER="0" ALIGN="center" CLASS="content">
    <TR><TD>
        <TABLE WIDTH="820" BORDER="0" ALIGN="center" CLASS="download" id="2">
               <TR>
            <TD CLASS="style" colspan="4"><IMG SRC="images/nav_staffnic.jpg" valign="bottom"></TD>
              </TR>
              <TR>
            <TD class="driver">
            <form id="frmlogin" method="post" action="Login">
            <p>ENTER USER NAME <input type="text" name="login_username" id="username"></p>
            <p> ENTER PASSWORD <input type="password" name="login_pass" id="password"><br><br>
              <input type="submit" class="button" value="Log in">
            </p>

            </form>
            </TD>
             </TR>
</TD></TR>
</TABLE> 
but when i run the file, i have got the message "document.frmlogin.login_username is null or not an object!"

Could you tell me what's wrong?
Thanks a lot!
Reply With Quote

  #2 (permalink)  
Old Mar 31st, 2008, 21:02
CloudedVision's Avatar
Nerdy Moderator
Join Date: Feb 2008
Location: In My Own Little World
Age: 14
Posts: 942
Blog Entries: 8
Thanks: 2
Thanked 22 Times in 22 Posts
Send a message via AIM to CloudedVision Send a message via MSN to CloudedVision Send a message via Skype™ to CloudedVision
Re: Login form using JavaScript and XML

Quote:
Originally Posted by niceman View Post
Hi guys!
I'm studying Java.
Please note that java and javascript are to VERY different languages.

Quote:
Originally Posted by niceman View Post
Could you tell me what's wrong?
Thanks a lot!
Try adding name="frmlogin" to the form tag. Not sure if that will work...
__________________
echo "Take it easy, ".$CloudedVision;
.links { site: other-road-design; blog: only-nerds-allowed; project: resource-fish; organization: ARMIES6; }
<quote>&quot;I think it's wrong that only one company makes the game Monopoly&quot; - <name>Steven Wright</name></quote>
Last Blog Entry: More Cheat Sheets (Jul 12th, 2008)
Reply With Quote
  #3 (permalink)  
Old Apr 1st, 2008, 12:44
Aso's Avatar
Aso Aso is offline
Chief Moderator

SuperMember
Join Date: Oct 2007
Location: UK
Posts: 1,012
Blog Entries: 2
Thanks: 5
Thanked 23 Times in 20 Posts
Send a message via Skype™ to Aso
Re: Login form using JavaScript and XML

Actually, you could just use;
Code: Select all
var frmlogin = document.getElementById("frmlogin");
at the start. But make sure to then refer to it as frmlogin (instead of document.frmlogin).
Last Blog Entry: The Google Misconception (Feb 3rd, 2008)
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Login Script / form prydie PHP Forum 0 Mar 27th, 2008 06:55
Javascript for Login Button jayaramgussy JavaScript Forum 1 Jul 5th, 2007 21:12
Login Form Stuck Aaron1988 PHP Forum 4 Apr 18th, 2007 20:33
web form login help mckeegan375 Web Page Design 7 Apr 15th, 2007 01:54
Flash login form? bob_visualefx Flash & Multimedia Forum 7 Nov 8th, 2006 03:33


All times are GMT. The time now is 19:40.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43