On Apr 19, 12:21 am, Lee <REM0VElbspamt...@cox.net> wrote:
> shimmyshack said:
>
>
>
>
>
> >On Apr 18, 9:19 pm, Bob Sanderson <sand...@LUVSPAMsandmansoftware.com>
> >wrote:
> >> 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';re turn 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.
>
> I can't speak for Randy, but it's lousy code.
> You abuse a link just for a side-effect and then use the least
> efficient way to access the field.
>
> --
javascript when it isnt used unobtrusively is indeed an abuse; as is
buffing one's own ego while sitting on the other hand.
|