PDA

View Full Version : tooltip with forms in php?



Utech22
September 27th, 2008, 05:38 AM
I don't really want to use javascript.
What I want to do is to have a descriptive tooltip displayed
when I user clicks a form field.

http://img218.imageshack.us/img218/8730/kirpyv7.jpg

When the user clicks the input box, the text "Enter your name" is displayed or something similar to that effect.
and so on for the others.

simplistik
September 27th, 2008, 11:45 PM
has to be javascript

Templarian
September 28th, 2008, 12:55 AM
I use CSS on a few apps at work by using the basic CSS rollovers with the silk "help" icon, usually looks pretty nice, but for what you want simp is right has to be JS.

Utech22
September 28th, 2008, 11:25 PM
has to be javascript
What I was pseudocoding was:



$message_name = "Enter your name";



<input type="text" name="name" onclick="<?php echo $message_name;?> />


Or something similar.

Templarian
September 28th, 2008, 11:47 PM
^onclick is a javascript event handler and doesn't work like how your using it.

ajcates
September 29th, 2008, 12:26 AM
What you are looking for is onfocus, something like this can be easily achieved using javascript. I use it on http://www.websiteninjas.com/contact-us

You can still the javascript and css file if you would like.

Utech22
September 29th, 2008, 10:15 AM
.................... http://www.websiteninjas.com/contact-us
.....................

Your validation is not working, I just test it in IE6.

tfg
September 29th, 2008, 10:20 AM
use the title attribute if you want a tooltip to appear near the mouse. (like hovering over the title of a thread on this forum)

or you can use css popups if you want it to appear as part of the page. http://meyerweb.com/eric/css/edge/popups/demo.html

simplistik
September 29th, 2008, 12:45 PM
if for some reason you wanted the variables for your messages to be php values, you can always go a javascript/json route. you have your json encoded array in some sort of storage file, so like


$messages = array(
'first_name' => "Please enter your first name.",
'last_name' => "Please enter your last name."
);

then with javascript import that data via json and it could dynamically show that tooltip.