View Full Version : Filling a value on doc load ?

12-30-2008, 08:57 PM

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:

<script type="text/javascript">
function chg_name() {

function chg_pass() {

function set_things(){
document.login_fm1.x_screen_name.value="screen name";

} // end of function

// -->

In my html I have this:

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

12-31-2008, 09:57 AM
http://www.codingforums.com/showthread.php?t=131094 may help.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum