...

View Full Version : Title to Option Tag in Select Box



praveen.2
09-13-2011, 10:33 AM
How to add title to options in Select box , where the options are generated from the data base.
Any idea

devnull69
09-13-2011, 12:35 PM
So when you create the options in the first place (using PHP or whatever?) you can just add a title attribute to each option.

If you want to add a title attribute using Javascript after the select box has been created, you can use the getElementsByTagName('option') collection of the select box like that


// get the select box named "myselect"
var mySelect = document.getElementsByName('myselect')[0];
// get all its options
var theOptions = mySelect.getElementsByTagName('option');
for(i=0; i<theOptions.length; i++) {
theOptions[i].title = 'This is title #' + i;
}

niralsoni
09-13-2011, 12:36 PM
Did you tried this one ??



<SELECT>
<OPTION TITLE="Description of the option-1">Option 1
<OPTION TITLE="Description of the option-2">Option 2
</SELECT>


Thanks & Regards,



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum