Page 1 of 1
how to empty a textbox when a button is clicked
Posted: Fri Jan 30, 2004 5:39 pm
by vigge89
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...
Posted: Fri Jan 30, 2004 5:54 pm
by Unipus
document.GetElementbyId('textbox').value = "";
but shouldn't it be emptied by default?
Posted: Sat Jan 31, 2004 2:59 am
by vigge89
no, you see, the form is on the main 'window', but then it's target is an iframe, so the text stays...
but i'll try your code out, thanks!
Posted: Sat Jan 31, 2004 3:35 am
by vigge89
doesn't seem to work, I use this:
Code: Select all
function clear_field(field) {
document.GetElementbyId(field).value = '';
}
but when i call the function trough:
Code: Select all
OnClick="javascript:clear_field('shout_message');"
it doesn't work
the textbox is named and got the id 'shout_message', but it still doesn't work...
Posted: Sat Jan 31, 2004 2:10 pm
by vigge89
anyone?
Posted: Wed Feb 11, 2004 12:02 pm
by no_memories
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
