0

my application is asp.net MVC3. I am using Telerik MVC combobox; I need to highlight a specific word in the dropdownlist, here is my script:

 highlightText(document.getElementById('Cword').value);

function highlightText(htext) {
    var str = document.getElementById("ComboBox-input").innerHTML;
    str = str.replace(htext, '<span style="color:blue;">' + htext + '</span>');
    document.getElementById("ComboBox-input").innerHTML= str;
}

Unfortunately it did not work, I check same script on a div and it worked. I would appreciate your suggestions, thanks in advance.

hncl
  • 2,295
  • 7
  • 63
  • 129
  • Your approach is not working because you are trying to insert span element into an input element which is not possible. Similar question here: http://stackoverflow.com/questions/6499163/span-inside-text-input-field – Petur Subev Feb 19 '13 at 06:11

1 Answers1

1

Please check the answer in which specfic combo values are highlighted.

Telerik Combo Background

Get the index of that value using above approch after access use

$("#combobox").select(index);
Community
  • 1
  • 1
enigma
  • 82
  • 1
  • 2
  • 11