Welcome to Dream.In.Code
Getting Help is Easy!

Join 136,339 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,793 people online right now. Registration is fast and FREE... Join Now!




Clear input field

 
Reply to this topicStart new topic

Clear input field, How to clear text in text field on click?

Zumiic
26 Aug, 2008 - 01:35 AM
Post #1

New D.I.C Head
*

Joined: 20 Nov, 2007
Posts: 13


My Contributions
I have a basic input with starting value.

<input type="text" name="topic" value="Enter topic here"/>


wanted to ask how to clear the starting value when user click inside the element. I heard something about onmousedown or onclick or something like that. But tried all kind of ways and no results. Also cant find anything on web.

I know its nothing hard - but i would really aprreciate the help smile.gif

Tnx

Zumiic
User is offlineProfile CardPM
+Quote Post

commanderderjukes
RE: Clear Input Field
26 Aug, 2008 - 01:46 AM
Post #2

New D.I.C Head
*

Joined: 28 Jan, 2008
Posts: 46


My Contributions
are you sure you have tried online and havent found anything?this question is very simple and i think that you havent tried anythng b4 coming here . try googling set text field to empty after clicking .try googling or give some sample code of what you have done. you would be surprised at the amount of help you might get .


User is offlineProfile CardPM
+Quote Post

Zumiic
RE: Clear Input Field
26 Aug, 2008 - 02:00 AM
Post #3

New D.I.C Head
*

Joined: 20 Nov, 2007
Posts: 13


My Contributions
well i got it working with his:

<input type="text" id="topic" name="topic" value="Topic here" onmousedown="document.getElementById('topic').value =''"/>


but when i refresh the same page the text is empty again smile.gif
How to get it back?

This post has been edited by Zumiic: 26 Aug, 2008 - 02:02 AM
User is offlineProfile CardPM
+Quote Post

commanderderjukes
RE: Clear Input Field
26 Aug, 2008 - 02:46 AM
Post #4

New D.I.C Head
*

Joined: 28 Jan, 2008
Posts: 46


My Contributions
QUOTE(Zumiic @ 26 Aug, 2008 - 03:00 AM) *

well i got it working with his:

<input type="text" id="topic" name="topic" value="Topic here" onmousedown="document.getElementById('topic').value =''"/>


but when i refresh the same page the text is empty again smile.gif
How to get it back?


pass the data to the next page using a post or a session or a getvariable and assign the value to it when the page reloads or set the default value of that input to what you want
.read on session ,post and get variables
User is offlineProfile CardPM
+Quote Post

Zumiic
RE: Clear Input Field
26 Aug, 2008 - 02:57 AM
Post #5

New D.I.C Head
*

Joined: 20 Nov, 2007
Posts: 13


My Contributions
tnx - the defaultValue works fine smile.gif

This post has been edited by Zumiic: 26 Aug, 2008 - 02:58 AM
User is offlineProfile CardPM
+Quote Post

commanderderjukes
RE: Clear Input Field
26 Aug, 2008 - 03:14 AM
Post #6

New D.I.C Head
*

Joined: 28 Jan, 2008
Posts: 46


My Contributions
QUOTE(Zumiic @ 26 Aug, 2008 - 03:57 AM) *

tnx - the defaultValue works fine smile.gif


happy to help smile.gif
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 08:11AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month