Forum Moderators: open

Message Too Old, No Replies

Allow onMouseDown event only once

         

dougmcc1

10:41 pm on Apr 22, 2009 (gmt 0)

10+ Year Member



In my form I have default values for my form fields. When somone clicks on the form field for the first time I want to remove the default text and replace it with whatever they type in. However, I dont want to remove what they typed in if they happen to click on the form field again.

For example, a form field might be Description and the default text might be "Type a Description". When they click on the field to enter a description, the field turns blank. After they write a description, I dont want it to disappear if they click on that field again.

This didnt work:
<input name="Description" type="text" value="Type a Description" onMouseDown="if(this.value='Type a Description'){this.value=''};this.style.fontStyle='normal';this.style.fontWeight='bold'" />

It thinks the value is always "Type a Description" even when I type something different in there.

astupidname

11:08 pm on Apr 22, 2009 (gmt 0)

10+ Year Member



if(this.value='Type a Description'){

It thinks the value is always "Type a Description" even when I type something different in there.

You are using single = and therefore assining value, you intend to use double ==

dougmcc1

11:15 pm on Apr 22, 2009 (gmt 0)

10+ Year Member



Ah, that fixed it. Thanks for the super fast reply.