jeddi
12-30-2008, 08:57 PM
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:
<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:
<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 :)
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() {
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:
<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 :)