Jump to content
  • Checkout
  • Login
  • Get in touch


The e-commerce.

Adding an onfocus event handler in php?


Recommended Posts

In search.php I am trying to achieve a text box that says, "Enter search term", onBlur and is blank when onFocus. Easy to do in HTML, but how do you make it work in PHP?


Here's my code:


'text' => tep_draw_input_field('keywords', '', 'size="10" value="Enter search term" onFocus="if(this.value=='Enter search term')this.value='';" onblur="if(this.value=='')this.value='Enter search term';" maxlength="30" style="width: ' . (BOX_WIDTH-30) . 'px"') . ' ' . tep_hide_session_id() . tep_image_submit('button_quick_find.gif', BOX_HEADING_SEARCH) . ' ' . BOX_SEARCH_TEXT);


What am I doing wrong?


All help appreciated.



Leah :)

Link to comment
Share on other sites

To explain a bit more detail, it's for the search box. I've seen it done in other sites, and have no idea how to get it working. Adding the HTML code (like I've done above) doesn't seem to work. Any suggestions?


Thanks in advance.

Link to comment
Share on other sites

Try this:


'text' => tep_draw_input_field('keywords', '', 'size="10" maxlength="30" style="width: ' . (BOX_WIDTH-30) . 'px" onmousedown="this.value=\'\'" value="Enter search term"') . ' ' . tep_hide_session_id() . tep_image_submit('button_quick_find.gif', BOX_HEADING_SEARCH) . ' ' . BOX_SEARCH_TEXT);


You may need to make it a little wider, to fit "Enter search term" in.

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...