Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

HTML Forum


You are currently viewing our HTML Forum as a guest. Please register to participate.
Login



Post a Project »

Find a Professional HTML Freelancer!

Find a Freelancer to help you with your HTML projects

FREE Outsourcing eBook!

Reply
Removing Text Value in Textarea upon Selection?
Old 04-09-2010, 01:48 PM Removing Text Value in Textarea upon Selection?
Madman340's Avatar
Web Designer

Posts: 571
Name: Jared
Location: Florida
Trades: 1
If I set a textarea/input element's value to "Click here" how can I make "Click here" go away after it is selected?
__________________

Please login or register to view this content. Registration is FREE
for cheap hosting solutions.
Use the coupon code "SINGLECENT" to pay just a single cent for the first month!
Madman340 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-09-2010, 02:35 PM Re: Removing Text Value in Textarea upon Selection?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,380
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
onclick="this.value='' " or onfocus

Be aware that IF the user clicks back into the field it WILL clear their input.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 04-09-2010, 02:39 PM Re: Removing Text Value in Textarea upon Selection?
Novice Talker

Posts: 11
Trades: 0
Hi Madman340.

Quick example:
Code:
<script>
function clearValue( object ) {
	if ( object.innerHTML == 'Click here' ) {
		object.innerHTML = '';
	}
}
</script>

<textarea onFocus="clearValue( this );">Click here</textarea>
__________________

Please login or register to view this content. Registration is FREE
.:. Professional Hosting since 2003
2wdh.com is offline
Reply With Quote
View Public Profile Visit 2wdh.com's homepage!
 
Old 04-09-2010, 05:19 PM Re: Removing Text Value in Textarea upon Selection?
Madman340's Avatar
Web Designer

Posts: 571
Name: Jared
Location: Florida
Trades: 1
I think that is exactly what I'm looking for 2wdh, although how would I do that with an input area? (Such as a search bar)

I don't know javascript, so I'm pretty helpless at this point.


Right now I have this:

Code:
<script>
   function clearValue( object ) {
	if ( object.innerHTML == 'search' ) {
	object.innerHTML = '';
	}
   }
</script>

<input type="text" onFocus="clearValue( this );" name="search" value="search" id="search_text" size="14" />
__________________

Please login or register to view this content. Registration is FREE
for cheap hosting solutions.
Use the coupon code "SINGLECENT" to pay just a single cent for the first month!

Last edited by Madman340; 04-09-2010 at 05:21 PM..
Madman340 is offline
Reply With Quote
View Public Profile
 
Old 04-10-2010, 04:12 PM Re: Removing Text Value in Textarea upon Selection?
Novice Talker

Posts: 11
Trades: 0
Hi Madman340.

For input field it should be object.value. I.e.:
Code:
<script>
   function clearValue( object ) {
	if ( object.value == 'search' ) {
	object.value = '';
	}
   }
</script>

<input type="text" onFocus="clearValue( this );" name="search" value="search" id="search_text" size="14" />
Feel free to ask if you need any further assistance.
__________________

Please login or register to view this content. Registration is FREE
.:. Professional Hosting since 2003
2wdh.com is offline
Reply With Quote
View Public Profile Visit 2wdh.com's homepage!
 
Reply     « Reply to Removing Text Value in Textarea upon Selection?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.35167 seconds with 12 queries