Forums
This topic is locked
Replace textbox text when clicked
Posted 23 May 2003 18:27:21
1
has voted
23 May 2003 18:27:21 Dan Berdusco posted:
There is probably a very simple solution to this problem but I can't seem to figure it out. I have a small form with one textbox for the username to enter their email address to sign up to a mailing list. I have a default value in the textbox that says "Enter email address here" to let users know what to do. My question is, how can I make it so that as soon as the user clicks in the text box, the text disappears without the user having to highlight the text and hit the "delete" key?A sample of what I would like to do can be viewed at www.weather.ca anc click in the city search textbox at the top of the page.
Thanks.
Replies
Replied 23 May 2003 19:17:21
23 May 2003 19:17:21 Owen Eastwick replied:
JavaScript functon something like this should do what your example does:
In the head with all the other JavaScript functions:
function ClearText(){
document.formName.textFieldName.value = "";
}
function ReplaceText(){
document.formName.textFieldName.value = "enter city";
}
The text box:
<input type="text" name="textFieldName" onClick="ClearText()" onMouseOut="ReplaceText()">
Regards
Owen.
-------------------------------------------------------------------------------------------
Used programming books and web development software for sale (UK only): www.tdsf.co.uk/tdsfdemo/Shop.htm
Developer services and tutorials: www.drdev.net
Multiple Parameter UD4 / Access 2000 Search Tutorial: www.tdsf.co.uk/tdsfdemo/
In the head with all the other JavaScript functions:
function ClearText(){
document.formName.textFieldName.value = "";
}
function ReplaceText(){
document.formName.textFieldName.value = "enter city";
}
The text box:
<input type="text" name="textFieldName" onClick="ClearText()" onMouseOut="ReplaceText()">
Regards
Owen.
-------------------------------------------------------------------------------------------
Used programming books and web development software for sale (UK only): www.tdsf.co.uk/tdsfdemo/Shop.htm
Developer services and tutorials: www.drdev.net
Multiple Parameter UD4 / Access 2000 Search Tutorial: www.tdsf.co.uk/tdsfdemo/