I've written a php function script to check the a default value of a text field during an onFocus and onMouseOut events.
The default value of the text field is 'Search'.
When a user sets focus on the text field, the value should clear to empty string.
When the user removes focus and without entering a text, the value should be set back to 'Search'.
Else a $value variable should be assigned the value of the user input in the text field.
Please see the code below and help me out - cos, I am having problem calling the script on the input field. I'm not even sure whether the script is wrong or not...
Expand|Select|Wrap|Line Numbers
- <?php
- function setValue()
- {
- if (!empty($_REQUEST['qfront']) && $_REQUEST['qfront']=='Search')
- {
- $value=''; //$_REQUEST['qfront']="";
- }
- elseif (!empty($_REQUEST['qfront']) && $_REQUEST['qfront']!='Search')
- {
- $value=$_REQUEST['qfront'];
- }
- else //if (empty($_REQUEST['qfront'])
- {
- $value='Search';
- }
- return setValue();
- }
- ?>