Dynadot โ€” .com Transfer

Very cool Javascript function - alternative to onclick="this.value=''"

SpaceshipSpaceship
Watch

Scott

Senior MemberVIP Member
Impact
49
I found this at SPF - http://www.sitepoint.com/forums/showthread.php?t=228732 - but I changed it around a little to support multiple input boxes.

Instead of using something such as;

Code:
onclick="this.value=''"

in a textbox like...

Code:
<input type="text" name="email" value="Enter your email address" onclick="this.value=''" />

and then when you click off and back on to edit something, it resets it again, you can use this function;

Code:
<script language="Javascript">
<!--
function resetBox(box, defaultvalue) {
  if (box.value == defaultvalue) {
   box.value = "";
   }
}
-->
</script>

This way, you can use a textbox like this;

Code:
<input type="text" name="email" value="enter your email" onfocus="resetBox(this, 'enter your email')" />
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
Looks interesting. I used to know a lot of javascript when I first started HTML and stuff, but now I've forgotten it to bigger powers, ie: php!

My most interesting script was a scrolling background, so that a background picture could be made to scroll from the bottom to the top of the page.

:) those were the days!
 
0
•••
what does it do.... lol I have about 50 tabs open on firefox and I dun wanna open anymore... ... ill check later
 
Last edited:
0
•••
it makes it so if a text box contains the default text and a visitor clicks it, the text box will clear itself. Its a space saver: put the input dsecription in the box rather than next to it.

I use a similar way for the login form on www.cheatdose.com
 
0
•••
PoorDoggie said:
Looks interesting. I used to know a lot of javascript when I first started HTML and stuff, but now I've forgotten it to bigger powers, ie: php!

My most interesting script was a scrolling background, so that a background picture could be made to scroll from the bottom to the top of the page.

:) those were the days!

why quit one to learn the other? LEARN 'EM ALL!!! muahahaha
:lol:

Besides using javascript is completely different then using PHP... there is so much you can do by mixing javascript into your PHP code that makes it AWESOME for instance... click on my name over there <<<< that nice looking menu that comes out isnt in PHP, but this forum is. Its those cool little extra effects that give your projects that extra push they need to make someone go "Wow, i wanna hier this guy again" :D
 
0
•••
looks cool, i'll be using it

thanks alot
 
0
•••
Dynadot โ€” .com TransferDynadot โ€” .com Transfer
Appraise.net
Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomDB
NameFit
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back