Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    New to the CF scene
    Join Date
    May 2007
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up (Solved)Problem with Login / Password (document....==document... not working)

    _______________________________________________________________

    This part is all fixed:
    (Look to my last post)







    Hello, I'm pretty new on javascript, I don't know much about it but I'm willing to learn, so I've started coding a login for a website I've created already, here's the problem:

    This first part of the code is importantless;
    Code:
    <html>
    <form name=regist>
    <table align=center border="0">
    <tr><td colspan=2 align=center><strong>Registering New Account</strong></td></tr>
    <td></td>
    <tr><td>Login : </td><td><input type="text" name="login" size=12></td></tr>
    <tr><td>Password : </td><td><input type="password" name="password" size=12></td></tr>
    <tr><td colspan=2 align=center><input type="button" value="Send" onClick="load=onck()"></td></tr>
    </table>
    </form>
    
    <script language = "javascript">
    function onck()
    {
    	alert("Your login and password has been saved, you may now login.")
    	window.open('Login.htm')
    }
    
    </script>
    </html>
    Here's the code I can't work with:
    Code:
    <html>
    <form name=regist>
    <table align=center border="0">
    <tr><td colspan=2 align=center><strong>Logging In</strong></td></tr>
    <td></td>
    <tr><td>Login : </td><td><input type="text" name="login" size=12></td></tr>
    <tr><td>Password : </td><td><input type="password" name="password" size=12></td></tr>
    <tr><td colspan=2 align=center><input type="button" value="Login" onClick="load=onck()"></td></tr>
    </table>
    </form>
    
    <script language = "javascript">
    function onck()
    {
    	alert("You are now logged in")
    	alert("Welcome",login)
    }
    </script>
    </html>

    So, the thing is, I want "alert("Welcome",login)" that login to connect with the login inside the table - input type =text, I guess I need a var to make that work, but I don't know how to make that work on html / javasc.

    Can you help me out?

    If you didn't understood yet, I'll make it simple:

    <input type="text" name=login onClick="load=conf()">

    function conf()
    {
    if (login==login1) { ...... }
    }

    Is that possible?


    Thanks in advance

    _______________________________________________________
    Last edited by Bull; 05-12-2007 at 06:03 PM. Reason: Already got it.

  • #2
    Regular Coder
    Join Date
    May 2007
    Posts
    118
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi Bull ,

    I don't understand you too much but anyway a few tips..

    Don't use this syntax:
    .. onClick="load=onck()">
    But just this syntax:
    .. onClick="onck()">
    If you want to test the value of some input text, you can use this code:
    Code:
    <td><input type="text" id="login" name="login" size=12>
    
    <script language = "javascript">
    function conf()
    {
    if (document.getElementById('login').value=='value')
      alert('Welcome '+document.getElementById('login').value); else
      alert('Incorrect login');
    }
    </script>
    Last edited by smalldog; 05-12-2007 at 03:03 PM.
    Forum for webmasters and developers
    http://www.htmlfrenzy.com
    Are you an IT expert? Join our Reward system
    www.htmlfrenzy.com/reward-system.php

  • #3
    New to the CF scene
    Join Date
    May 2007
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    id="login", That's just what I was looking for, thank you very much smalldog


    Sorry for the mess on the other post

  • #4
    New to the CF scene
    Join Date
    May 2007
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Stuck again ...



    Code:
    function RegCom()
    {
    if (document.getElementById('login').value=='' || document.getElementById('password').value=='')
    	{
    	alert("Please fill all fields")
    	}
    	else
    	{
    	alert("Registration complete")
    	load="Registrationlog()"
    	}
    }
    
    
    function Registrationlog()
    .....

    Can anyone explain me why load isn't working? I've tried it several ways but nothing.

    Ty.

  • #5
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,017
    Thanks
    203
    Thanked 2,538 Times in 2,516 Posts
    load="Registrationlog()"

    There is no "load" command in JavaScript.

    To call the function, simply:-

    Registrationlog();

  • #6
    New to the CF scene
    Join Date
    May 2007
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Buuu me, I did knew that but I thought it wasn't working, now I realize I hadn't finished the Registrationlog() function yet, sorry and thank you once again.

  • #7
    New to the CF scene
    Join Date
    May 2007
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    And still...


    Code:
    if (document.getElementById('login2').value==document.getElementById('login1').value)

    Isn't this doable? It's not working but I need that, I need a second text box to verify if the login is the same has in the first text box

  • #8
    Regular Coder
    Join Date
    May 2007
    Posts
    118
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Your code is correct, however you can't compare one text box from previous page with text box on current page.. simply - you can just compare two inputs on the same page..
    Forum for webmasters and developers
    http://www.htmlfrenzy.com
    Are you an IT expert? Join our Reward system
    www.htmlfrenzy.com/reward-system.php

  • #9
    New to the CF scene
    Join Date
    May 2007
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    geez, my mistake once again, there is no "login1" there's "login" and "login2"


    Sorry again, I need to pay more attention to my code.

  • #10
    Regular Coder
    Join Date
    May 2007
    Posts
    118
    Thanks
    0
    Thanked 0 Times in 0 Posts
    No problem..
    Forum for webmasters and developers
    http://www.htmlfrenzy.com
    Are you an IT expert? Join our Reward system
    www.htmlfrenzy.com/reward-system.php


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •