...

View Full Version : (Solved)Problem with Login / Password (document....==document... not working)



Bull
05-12-2007, 02:46 PM
_______________________________________________________________

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;

<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:

<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

_______________________________________________________

smalldog
05-12-2007, 02:59 PM
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:


<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>

Bull
05-12-2007, 03:10 PM
id="login", That's just what I was looking for, thank you very much smalldog :thumbsup:


Sorry for the mess on the other post :p

Bull
05-12-2007, 04:19 PM
Stuck again :(...




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.

Philip M
05-12-2007, 04:49 PM
load="Registrationlog()"

There is no "load" command in JavaScript.

To call the function, simply:-

Registrationlog();

Bull
05-12-2007, 05:01 PM
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.

Bull
05-12-2007, 05:28 PM
And still...



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

smalldog
05-12-2007, 05:53 PM
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..

Bull
05-12-2007, 06:03 PM
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.

smalldog
05-12-2007, 06:08 PM
No problem.. :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum