How can I empty a textbox trough JS when a button is clicked (form submitted)?
this is probably very easy, but i know nothing about JS, so i have no idea...
how to empty a textbox when a button is clicked
Moderator: General Moderators
doesn't seem to work, I use this:
but when i call the function trough:
it doesn't work
the textbox is named and got the id 'shout_message', but it still doesn't work...
Code: Select all
function clear_field(field) {
document.GetElementbyId(field).value = '';
}Code: Select all
OnClick="javascript:clear_field('shout_message');"the textbox is named and got the id 'shout_message', but it still doesn't work...
- no_memories
- Forum Contributor
- Posts: 145
- Joined: Sun Feb 01, 2004 7:12 pm
- Location: New York City
try this:
<input type="" onfocus="this.value=''"> <----- single line entry.
or
<textarea onfocus="this.value=''"> <----- multi line entry.
There is no complex script needed really. Just clear the text area with onfocus.
BTW, you can also add a value to the onfocus, ie, onfocus="this.value=''Put Your Text Here"
Hope This Helps
<input type="" onfocus="this.value=''"> <----- single line entry.
or
<textarea onfocus="this.value=''"> <----- multi line entry.
There is no complex script needed really. Just clear the text area with onfocus.
BTW, you can also add a value to the onfocus, ie, onfocus="this.value=''Put Your Text Here"
Hope This Helps