Page 1 of 1

Interactive login... nothing fancy really

Posted: Sat May 17, 2003 9:43 am
by mikusan
One line of code that i need some directive in...
i think this can be done in java script and i dun care really php would be nice... but i really don't mind

Code: Select all

<tr> 
            	<form action="auth.php" method="post">
<!--                	<table border="0" cellspacing="0" cellpadding="3">	-->
                    	<td colspan="2"><b>Login:</b></td>
                        	<tr>
 	                           <td><input type="text" size="16" name="username" value="Username"></td>
                            </tr>
                            <tr>
                     	       <td><input type="password" name="passwd" size="15" value="123"></td>
                            </tr>
                            <tr>
                               <td align="left">
                               <input type="submit" value="Submit">
                               </td>
                            </tr>
<!--                    </table>											-->
                 </form>
              </tr>
This is my login form... because of space onstraints i wish to give an initial value to fields... hence you will see

BUT... as you can see you have to select the words and then put things in...I would like to be able to click and the whole field resets to blank....

thx so much...

Posted: Sat May 17, 2003 1:26 pm
by boinnk
Use onFocus="" in the <input>

Code: Select all

<input type="text" size="16" name="username" value="Username" onFocus="this.value='';">

Posted: Mon May 19, 2003 9:27 am
by lazy_yogi
or you could use this

Code: Select all

<HTML>
<HEAD>

<SCRIPT language=JavaScript>
<!--  // clears default values from input boxes
function clearText(thefield)&#123;
  if (thefield.defaultValue==thefield.value) thefield.value = ""
&#125; // -->

</SCRIPT>

</HEAD>
<BODY>

<INPUT name="name" onfocus=clearText(this) value="Your Name"></TD></TR>

the only difference is that with the previous post, if you type someting, and then before submitting it, if you click somewhere else - When you come back you're own input clears itself.

Cheers

Posted: Mon May 19, 2003 1:07 pm
by mikusan
I was hoping to use the above one as i don't want to have too much JavaScript lying around because i use templates to parse my html files... and anything extra i add into the php... however, that line did not work on my website, but since i don't own the webserver and the admins there aren't giving me slack i cannot see the logs... i get a blank page...