HighDots Forums  

Clear text field on focus extension

Macromedia Dreamweaver Macromedia Dreamweaver Discussions (macromedia.dreamweaver)


Discuss Clear text field on focus extension in the Macromedia Dreamweaver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Dooza
 
Posts: n/a

Default Clear text field on focus extension - 12-01-2005 , 10:11 AM






Hi there,
Does anyone know of an extension or code snippet, that will clear the
text field of its current value when you click on it?

Kind regards,

Steve

Reply With Quote
  #2  
Old   
Dooza
 
Posts: n/a

Default Re: Clear text field on focus extension - 12-01-2005 , 10:18 AM






Dooza wrote:
Quote:
Hi there,
Does anyone know of an extension or code snippet, that will clear the
text field of its current value when you click on it?

Kind regards,

Steve
I should really search first, then post, as I just found the answer:

function clearDefault(el) {
if (el.defaultValue==el.value) el.value = ""
}

Next, you need to call this script from the onfocus event of your input
text box:

E-Mail:
<INPUT TYPE=text
VALUE="E-Mail Address"
ONFOCUS="clearDefault(this)">

Hopefully this will help someone else

Steve


Reply With Quote
  #3  
Old   
Murray *TMM*
 
Posts: n/a

Default Re: Clear text field on focus extension - 12-01-2005 , 10:45 AM



Hey - use this:

<input type="text" name="n" value="Your message"
onFocus="if(this.value==this.defaultValue)this.val ue=''"
onBlur="if(this.value=='')this.value=this.defaultV alue">

It works swell!

--
Murray --- ICQ 71997575
Team Macromedia Volunteer for Dreamweaver
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"Dooza" <steve (AT) arse (DOT) dooza.tv> wrote

Quote:
Dooza wrote:
Hi there,
Does anyone know of an extension or code snippet, that will clear the
text field of its current value when you click on it?

Kind regards,

Steve
I should really search first, then post, as I just found the answer:

function clearDefault(el) {
if (el.defaultValue==el.value) el.value = ""
}

Next, you need to call this script from the onfocus event of your input
text box:

E-Mail:
INPUT TYPE=text
VALUE="E-Mail Address"
ONFOCUS="clearDefault(this)"

Hopefully this will help someone else

Steve



Reply With Quote
  #4  
Old   
Dooza
 
Posts: n/a

Default Re: Clear text field on focus extension - 12-01-2005 , 12:30 PM



Murray *TMM* wrote:
Quote:
Hey - use this:

input type="text" name="n" value="Your message"
onFocus="if(this.value==this.defaultValue)this.val ue=''"
onBlur="if(this.value=='')this.value=this.defaultV alue"

It works swell!

Thank you Murray, it works very nicely!

Steve


Reply With Quote
  #5  
Old   
Murray *TMM*
 
Posts: n/a

Default Re: Clear text field on focus extension - 12-01-2005 , 12:34 PM



Yeah - I like it because it puts the default back when you click away if the
field has not been changed.

--
Murray --- ICQ 71997575
Team Macromedia Volunteer for Dreamweaver
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"Dooza" <steve (AT) arse (DOT) dooza.tv> wrote

Quote:
Murray *TMM* wrote:
Hey - use this:

input type="text" name="n" value="Your message"
onFocus="if(this.value==this.defaultValue)this.val ue=''"
onBlur="if(this.value=='')this.value=this.defaultV alue"

It works swell!


Thank you Murray, it works very nicely!

Steve



Reply With Quote
  #6  
Old   
Dooza
 
Posts: n/a

Default Re: Clear text field on focus extension - 12-01-2005 , 12:39 PM



Murray *TMM* wrote:
Quote:
Yeah - I like it because it puts the default back when you click away if the
field has not been changed.

That is the ideal way for it to work, and I am glad you posted it
becuase that reason alone made me not use the one that I found.

Steve


Reply With Quote
  #7  
Old   
Gary White
 
Posts: n/a

Default Re: Clear text field on focus extension - 12-01-2005 , 02:15 PM



On Thu, 01 Dec 2005 17:39:58 +0000, Dooza <steve (AT) arse (DOT) dooza.tv> wrote:

Quote:
That is the ideal way for it to work, and I am glad you posted it
becuase that reason alone made me not use the one that I found.

For an easy way to do it globally, see:
http://apptools.com/examples/dynamiceventhandler.php

Gary


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.