Page 1 of 1

A Call to PHP Function on INPUT field is not working

Posted: Thu Dec 13, 2012 10:28 pm
by Easytime
Script URL: localhost
Version of script: 5+
Hosting company: localhost
URL of phpinfo.php: localhost/
URL of session_test.php: localhost/
What terms did you try when SEARCHING for a solution:

Write your message below:
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...

Code: Select all

<?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();
}
?>

Thank you!.

Re: A Call to PHP Function on INPUT field is not working

Posted: Fri Dec 14, 2012 1:36 pm
by Klemen
Sorry, this is not a general PHP forum, but a forum where you can get help for scripts from www.phpjunkyard.com only!