...

View Full Version : Calling function not working



barkermn01
12-30-2007, 03:03 AM
Probley a noob error i just cant see it any help pls


<script type="text/javascript">
function user()
{
document.login.user.value='';
}

function pass()
{
document.login.pass.value='';
document.login.pass.type = 'password';
}

</script>
<center>Chat Login
<table>
<td>
<form name="login" methord="post">
<tr><input type="text" name="user" onclick="javascript:user()" value="Username"/></tr>
<tr><input type="text" name="pass" onclick="javascript:pass()" value="Password"/></tr>
<tr><input type="submit" name="go" value="login" disabled/></tr>
</form>
<td>
</table>
</center>

Can any one see the error if so pls post

There is another Error when i use this code tho


<input type="text" name="pass" onclick="javascript:document.login.pass.type='password';" value="Password"/>
but what i read this is a IE error not a Javascript error

Actinia
12-30-2007, 12:05 PM
There are a number of validation errors in your page. However, I have to admit that even if these are fixed, you still get a javascript error 'user() is not a function' or 'pass() is not a function.


<center>Chat Login
<form id="login" name="login" method="post" action="" >
<table>
<tr>
<td><input type="text" id="user" name="user" onclick="user();" value="Username" /></td>
<td><input type="text" id="pass" name="pass" onclick="pass();" value="Password" /></td>
<td><input type="submit" name="go" value="login" disabled="disabled" /></td>
</tr>
</table>
</form>
</center></body>


John

GJay
12-30-2007, 01:16 PM
name your functions differently from your form elements, that can cause problems.

You can't change the type of input elements once they're part of the document, so you'll either have to replace the element with a new one, or why not just use labels?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum