I need a JavaScript that will allow me to clear a field in a form when I
click an image next to it.
Any help will be greatly appreciated.
<input
type="text"
accesskey="s"
maxlength="50"
class="purplepic"
id="q"
name="q"
onblur="if(this.value=='')this.value='click here search our
site...';this.className='purplepic';"
onfocus="if(this.value=='click here search our
site...')this.value='';this.className='redpic';return true;"
value="click here search our site..."
/>
<a
title="click here to clear the search box"
id="reset"
href="javascript:void(0);"
onclick="clearit();return false;">
</a>
use a style sheet to style the link, or use an image with the onclick
instead.
here's the javascript:
function clearit()
{
var panel = document.getElementById('q');
panel.value='';
panel.focus();
}
Randy will hate this cos it uses gebi, but hey! And this is just a
copy and paste job from 2004, there are more "modern" unobtrusive
methods to do this, left as an exercise for the OP.