FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

Ajax login

 


DanielXP
I am making a ajax login thing for my site but the code I have is not getting the values of the username + password.

Code:
      echo '<table cellspacing="0"><form name="loginform" method="POST" onsubmit="lert(\'loading\'); login();return false;">
           <tr><td><label>Username:</label></td> <td><input type="text" name="username" size="19" /></td></tr>
           <tr><td><label>Password:</label></td> <td><input type="password" name="password" size="19" /></td></tr>
            <tr><td align="center" colspan="2"><input type="submit" value="Login" /></td></tr></form>
         </table>';


Thats my login form.

Code:
<script type="text/javascript" src="js/login.js"></script>


Thats how I am including the login.js script

Code:
function login(){
var username = document.loginform.username.value;
var password = document.loginform.password.value;
alert("Username: " + username + " Password: " + password)
}


Is my login.js file

and when I click the login button this is what the alert says.

Quote:
Username: Password:
jabapyth
try

Code:
<form name="loginform" id="loginform"

and
Code:
function login(){
var form=document.getElementById("loginform");
var username = form.username.value;
var password = form.password.value;
alert("Username: " + username + " Password: " + password);
}


if that doesn't work, post the link to the page here and we can check it out.

in any event get firebug. its a wonderful help for javascript debugging
DanielXP
jabapyth wrote:
try

Code:
<form name="loginform" id="loginform"

and
Code:
function login(){
var form=document.getElementById("loginform");
var username = form.username.value;
var password = form.password.value;
alert("Username: " + username + " Password: " + password);
}


if that doesn't work, post the link to the page here and we can check it out.

in any event get firebug. its a wonderful help for javascript debugging


Thanks, now working Very Happy
Reply to topic    Frihost Forum Index -> Scripting -> Html, CSS and Javascript

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.