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 3 of 3
  1. #1
    Regular Coder
    Join Date
    Nov 2007
    Location
    Leeds, UK
    Posts
    514
    Thanks
    24
    Thanked 19 Times in 19 Posts

    Question Calling function not working

    Probley a noob error i just cant see it any help pls

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

  • #2
    Regular Coder Actinia's Avatar
    Join Date
    Feb 2007
    Location
    Essex, UK
    Posts
    250
    Thanks
    1
    Thanked 23 Times in 22 Posts
    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.

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

  • #3
    Senior Coder
    Join Date
    Sep 2005
    Posts
    1,791
    Thanks
    5
    Thanked 36 Times in 35 Posts
    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?
    My thoughts on some things: http://codemeetsmusic.com
    And my scrapbook of cool things: http://gjones.tumblr.com


  •  

    Posting Permissions

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