This is a migrated thread and some comments may be shown as answers.

ComboBox text color changed in Javascript required

4 Answers 202 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 27 Nov 2010, 05:39 AM
Hi,

I'm using the classic AJAX controls (as required by the project upon which I am working - not negotiable).

I have a CheckBox which, when clicked, calls a javascript method setPostalAddressInRed()
In that method, a the text of a RadComboBox needs to be toggled between red and black i.e. if checked, red, if not checked black.
Paraphrasing my code, I have this:
setPostalAddressInRed() {
var isChecked = document.getElementById('AddressInactiveCheckBox').checked;
var
postState = document.getElementById('StatesComboBox');

if(isChecked == true) {
postState.style.color =
'red';}
else {
postState.style.color =
'black';
}
}

Unfortunately, that code is not working. It works for TextBoxes, but not RadComboBoxes.

Any help would be appreciated.

Cheers!

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 29 Nov 2010, 08:03 AM
 Hello David,

I suppose you are using RadCombox for ASP.NET (classic controls), Please go through the following documetation which shows how to get the client side object in this version.
http://www.telerik.com/help/aspnet/combobox/combo_client_basics.html

The complete documentation will be available here:
RadComboBox for ASP.NET

And if you are using RadControls for ASP.NET AJAX, then you need to use $find() method to get the client side object.
http://www.telerik.com/help/aspnet-ajax/combo_clientsidebasics.html

Thanks,
Princy.
0
David
Top achievements
Rank 1
answered on 29 Nov 2010, 02:28 PM
Hi Princy,

I'm able to get the RadComboBox assigned as a variable in the javascript. But I cannot figure out how to change the text to red. I've previously had a very close look at the documentation/API and there's nothing there that helps.

As far as I can see, the code that I wrote should have done the job.

So unfortunately, I'm still at a loss :(
0
Accepted
Kalina
Telerik team
answered on 29 Nov 2010, 11:05 PM
Hi David,

In case you use RadComboBox for ASP.NET AJAX please obtain the control client-side object and set the color of the input text in this way:
var combo2 = $find("<%=StatesComboBox2.ClientID %>");
var input = combo2.get_inputDomElement();
input.style.color = "red";

If you use RadComboBox for ASP.NET - you can do the same thing in this manner:
var combo1 =<%= StatesComboBox1.ClientID %>;
var input = document.getElementById("<%= StatesComboBox1.ClientID %>_Input");
input.style.color = "black";

I hope this helps.

Kind regards,
Kalina
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
David
Top achievements
Rank 1
answered on 30 Nov 2010, 01:13 AM

Hi Kalina,

Thank you so much. The _Input at the end was the bit I could not figure out. It works beatifully now.

Cheers

Tags
ComboBox
Asked by
David
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
David
Top achievements
Rank 1
Kalina
Telerik team
Share this question
or