Woodburn2006 Posted September 11, 2008 Share Posted September 11, 2008 this seems really simple but i cannot seem to find this anywhere on the net but when i have a value in a form field i want it to disappear when a user clicks in the field to add their own value, i see it everywhere but cannot find the method of doint it myself thanks alot Quote Link to comment https://forums.phpfreaks.com/topic/123836-clear-form-value-when-clicked/ Share on other sites More sharing options...
dropfaith Posted September 11, 2008 Share Posted September 11, 2008 http://snippets.dzone.com/posts/show/1256 Quote Link to comment https://forums.phpfreaks.com/topic/123836-clear-form-value-when-clicked/#findComment-639402 Share on other sites More sharing options...
tmbrown Posted September 11, 2008 Share Posted September 11, 2008 onclick="value='';" Example: <input type="text" name="MyTextBox" value="Some Value" onclick="value='';" /> From there on it becomes more complex. Quote Link to comment https://forums.phpfreaks.com/topic/123836-clear-form-value-when-clicked/#findComment-639403 Share on other sites More sharing options...
DarkWater Posted September 12, 2008 Share Posted September 12, 2008 tmbrown, that'll clear it out even if the user has the content that they want in the box. You need to make sure that there isn't the default value in there: <script type="text/javascript"> function clearThis(element) { if (element.defaultValue == element.value) { element.value = ''; } } </script> <input type="text" name="someinput" value="Enter something here!" onclick="clearThis(this)" /> Quote Link to comment https://forums.phpfreaks.com/topic/123836-clear-form-value-when-clicked/#findComment-639460 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.