Creating Rollover Tip on Web Forms Using JavaScript

This tutorial will teach you how to implement the tooltip rollover JavaScriptplugin using any custom form that you have. Tooltip rollovers are excellent for providing helpful tips at the very moment it is needed on your website. Additional information can be displayed for images, form field labels or certain blocks of text to assist visitors on your website.

Any type of HTML container can reveal a rollover when a cursor is placed over it. This includes div, span, etc. This can be achieved by giving an “onmouseover” attribute to containers. Additionally, this attribute lets you specify where the rollover should appear in relation to the container.

You also specify which information should be presented in the rollover itself, which is a very popular way among designers. The following example includes rollovers for an image (img container), form labels (span containers), a form button (input container), and text content in a div container

Here is an example of code for the rollover box div. Only one of these is required within the code on your page, regardless of how many boxes your page may contain.

The rollover box div should have an id attribute and the value must be unique on the page on your site. You may design the rollover box according to your preferences. For example, if you would like to add a style width definition or change the colors. Only two style definitions are required, the display: none and the position: absolute definitions.

The display: none definition causes the rollover to be hidden, invisible until the JavaScript (below) causes it to display. The position: absolute definition allows the JavaScript to position the rollover anywhere on your website. Include the rollover box div in the body area of your Pages code somewhere above the first spot where the rollover will be used.

Below is the code for the Tool-tip Plug-in:

Remember that when specifying the location of the rollover box, The rollover box is on top of the container with the on mouseover function, the rollover box will flip, rapidly displaying and hiding. This happens when the mouse is in the location within the container where the rollover box is displayed. When the rollover box displays, the mouse is seen as being over the rollover box, not the container, and the JavaScript will sense that the mouse has moved off the container.

Rollover Box
Then, as soon as the rollover is gone and the mouse is over the container again, the JavaScript will display the associated rollover box. The mouse is then again over the rollover box and the whole thing repeats. You can solve this issue by displaying the rollover box in another part of the container with the on mouseover function. Once the rollover box is positioned, it will stay positioned in the container, even if the container is moved to another part of the page.