[ic] onFocus clearing of search field

Jonathan Clark interchange-users@icdevgroup.org
Wed Jul 17 17:43:00 2002


> I seem to be tripping over myself.  What I'm attempting to do is
> extremely simple, that is having a search instruction in the search
> field and clearing it when focus is detected, yet I just be missing
> something and I'm sure it is probably a combination of the various
> browser DOM's and IC.  Here are a couple of the code segments if someone
> has any suggestions or alternatives:
>
> <script LANGUAGE="JavaScript" type="text/javascript">
> <!--
> function blankbox() {
>     document.site_search_form.mv_searchspec[1].value = "";
>     return 1;
>   }
> }
> //-->
> </script>
>                     <form action="[area search]" method=post
> name="site_search_form">
>                       <input type=hidden name=mv_session_id value="[data
> session id]">
>                       <table border="0" width="95%">
>                         <tr>
>                           <td align="left">
>                             <INPUT TYPE=hidden NAME=mv_coordinate VALUE=1>
>                             <INPUT TYPE=hidden NAME=mv_searchtype
> VALUE=db>
>                             <INPUT TYPE=hidden NAME=mv_matchlimit
> VALUE=[control matches 10]>
>                             <INPUT TYPE=hidden NAME=mv_sort_field
> VALUE=category>
>                             <INPUT TYPE=hidden NAME=mv_search_field
> VALUE="*">
>                             <input type=hidden name=mv_substring_match
> value=1>
>                             <INPUT TYPE=hidden NAME=mv_column_op VALUE=ne>
>                             <INPUT TYPE=hidden NAME=mv_column_op VALUE=rm>
>                             <INPUT TYPE=hidden NAME=mv_searchspec VALUE=1>
>                             <INPUT size=20 MAXLENGTH=40
> NAME=mv_searchspec type=text size=6 onFocus="blankbox();" value="Enter
> Model or Description">
>                           </td>


how about:

<INPUT size="20" MAXLENGTH="40" NAME="mv_searchspec" type="text"
value="Enter Model or Description"
 onFocus="javascript: if (this.value=='Enter Model or Description')
 this.value='';}" >

removing the extra 'size=' from the tag may help too..

Jonathan
Webmaint.