[Javascript] Arrays + Tooltip

Hassan Schroeder hassan at webtuitive.com
Thu Jan 20 12:09:42 CST 2005


Gonella Jayprakash wrote:

>          I am implementing tooltip in our application. When the user 
> points the cursor to each option in a dynamically populated select box, 
> there should be a tooltip displayed which contians information regarding 
> the option. 

> In the script, I am fetching each option which is dynamic and populating 
> an array in the following fashion:

> {   
>     titleInfo =  //some dynamic values
>     topArray[0] = new Option('<nobr title=titleInfo>Title Info</nobr>', "");
> }
> </script>

> In the  for loop, in each iteration there will be a dynamic value 
> populated in the variable *titleInfo. *I have to pass the *titleInfo* 
> variable to the <nobr title=??>Title Info</nobr>
> The above usage is giving a javascript error.

First of all, there's no such tag as <nobr>  :-)

Second, an option element can only contain PCDATA, no other elements.

However, an option element *can* have a title attribute, so you can
just assign it a value, e.g.

{
     titleInfo =  //some dynamic values
     topArray[0] = new Option("Title Info", "");
     topArray[0].title = titleInfo;
}

HTH!
-- 
Hassan Schroeder ----------------------------- hassan at webtuitive.com
Webtuitive Design ===  (+1) 408-938-0567   === http://webtuitive.com

                           dream.  code.





More information about the Javascript mailing list