473,472 Members | 1,717 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

A Call to PHP Function on INPUT field is not working

26 New Member
Dear Pros,

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
  1. <?php
  2. function setValue()
  3.    {
  4. if (!empty($_REQUEST['qfront']) && $_REQUEST['qfront']=='Search')
  5.    {
  6.  
  7.  $value=''; //$_REQUEST['qfront']="";
  8.    }
  9.    elseif (!empty($_REQUEST['qfront']) && $_REQUEST['qfront']!='Search')
  10.    {
  11.  $value=$_REQUEST['qfront'];
  12.     }
  13.    else //if (empty($_REQUEST['qfront'])
  14.    {
  15. $value='Search';
  16.    }
  17. return setValue();
  18. }
  19. ?>
  20.  
  21.  
Dec 13 '12 #1
3 2251
Rabbit
12,516 Recognized Expert Moderator MVP
PHP is a server side language. It will not run on the client's computer. What you want to do is run something when the client takes a certain action, to do that, you need to use a client side language like Javascript.
Dec 14 '12 #2
Easytime
26 New Member
I have a WAMP installed on my computer. I use PHP to script other functions and they run. I develop my files on php and they run just because I have installed WAMP on my pc. It;s just that, I'm having problem figuring out where the code has a bug that does not allow it to run.

Pls kindly help me.
Thank you!
Dec 14 '12 #3
Rabbit
12,516 Recognized Expert Moderator MVP
I didn't say PHP wouldn't run. But it will only run on your server. If you are trying to do something on the client's computer however, you will need to use a client side script like Javascript. onFocus and onMouseout events are client side events. Hence you need to use client side scripting. Like Javascript.
Dec 14 '12 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Rosebud | last post by:
Hello, I'd like some help trying to generate input fields on the fly. What I have on an HTML page is a single text input field labelled #1, e.g. #1 <input type="text">. Next to the field is a...
8
by: guillaume | last post by:
hello from france, I want to edit a list of customers dynamically and each row contains an input text with the name of customer and link to update the name the link calls the javascript ...
7
by: JW | last post by:
hello everybody I've got the following problem. I'm writing a form and I'm using javascript to validate fields (i.e. numeric, not blank). When my scripts detects an error I want it to put the...
2
by: Ron Aronica | last post by:
I want to specify the value of an input field using the return from a function. I want to do something this this: <script> function value() { return "the value"; } </script> <form>
4
by: please-answer-here | last post by:
Scenario: I'm using the following code to avoid that users use the return key in the middle of a form to submit the entire form ---- snip --------- function kH(e) { var pK = document.all?...
1
by: Adrian Parker | last post by:
v1.1 - After taking off smartnav (due to it not working properly), I've got code that will restore the scroll position of the page on postback, but now I'm looking at how to set focus on either a...
13
by: Lee | last post by:
I have this function that doesn't work. I pass it the td element and an id, and it makes an input field inside the td. That part workds. What doesn't work is that I want to add an "onkeyup" on...
1
by: nucleusnet | last post by:
I'll probably be laughed at for this attempt of coding, but all I am trying to do is read an input field, remove the "$" and write the new value in a different input field. function convert_action...
4
by: mfaisalwarraich | last post by:
Hi everybody, I have some problem so need some help. wat im trying to do is making a function which will change the value of a input field when the value of other input field is changed. im using...
0
by: brixton | last post by:
Hi, I've stumpled upon a very weird issue. The situation is that I'm styling my own file input field, by replacing it with a text field and a button, lying below the original file input, which...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.