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 2 of 2
  1. #1
    Senior Coder
    Join Date
    May 2006
    Posts
    1,680
    Thanks
    28
    Thanked 4 Times in 4 Posts

    Filling a value on doc load ?

    Hi

    I am having a problem with a simple bit of code ( I am new to ths)
    I'd like to fill a couple form fields when the screen loads.
    The idea is that inside the name input box is the word "screen name" and inside the password input box is the word "password and then when the user puts their curser on the box these words disappear.

    So I have this code:
    Code:
    <script type="text/javascript">
    <!--
    function chg_name() {
    document.login_fm1.x_screen_name.value="";
     }
    
    function chg_pass() {
    document.login_fm1.x_pass.value="";
     }
    
    function set_things(){
    document.login_fm1.x_screen_name.value="screen name";
    document.login_fm1.x_pass.value="password";
    
    }  // end of function
    
    document.onload=set_things()
    // -->
    </script>
    In my html I have this:

    Code:
    <div class="log_in">
        <form name="login_fm1" action ='index.php' method = 'POST'>
            <span><input type='hidden' name = 'run_mn1' value = 'yes' ></span>
    				<INPUT class="log_cell_inp" id="sc_name" name="x_screen_name" size="25px" type="text" onfocus="chg_name()" >
    				<INPUT class="log_cell_inp" id="sc_pass" name="x_pass"  size="28" type="password" onfocus="chg_pass()" >
    				<input class="button" type="submit" value="Login">
    		</form>
    		<a href="register.php">Register</a>
    </div> <!-- END LOGIN BOX -->
    The problem is - the boxes don't fill up

    Have I got the "document.onload=set_things()" wrong ?

    Thanks for any help
    Last edited by jeddi; 12-30-2008 at 09:00 PM.
    If you want to attract and keep more clients, then offer great customer support.

    Support-Focus.com. automates the process and gives you a trust seal to place on your website.
    I recommend that you at least take the 30 day free trial.

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,861
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)


  •  

    Posting Permissions

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