Dynamically changing form label colour

I am currently evaluating DHTMLX and I am trying to change a label text colour dynamically based on wetter I click on a checkbox. Ideally i would like to be able to use the form forEachItem function to switch all labels to a different colour.
this is ideally what i would like to do, I didn’t found how:

var theItem;
myForm.forEachItem(function(id, radioValue){
theItem = myForm.getItem ( id ); // this function doesn’t seem to exist
theItem.className = ‘myClassRed’; // or others colour that I will define.

I don’t want to use the validation function cause I need to be able to change the colour at any time to different colour.



there is no native method to change color, here is a workaround:

[code]// init
{type: “label”, name: “myLabel”, label: “Some text here”}

// change color
myForm.setItemLabel(“myLabel”, “New label”);[/code]

Thanks I tried that but unless I miss something, the next time you call getItemLabel, it now contains the ‘style’ extra code so I have to have special code to handle the first time setting it or when it was already set.

// init
{type: "label", name: "myLabel", label: "Some text here"}

// change color
myForm.setItemLabel("myLabel", "<span style='color:red;'>New label</span>");
myLabelText = myForm.getItemLabel("myLabel");
console.log ( myLabelText ); // will output "<span style='color:red;'>New label</span>"

in my case, I want to have a function that change the labels colours that use the colour in parameter. Right now, next time I call it, I end-up with:

New label

here is a subset of what it look like:

function changeTextColor ( pColor ){
    myLabelText = pForm.getItemLabel("myLabel");
    myNewText  = "<span style='  color:" + pColor + ";'>" + myLabelText + "</span>";
    pForm.setItemLabel("myLabel", lText);

changeTextColor ( 'blue' );
changeTextColor ('red'); //<span style='color:red;'><span style="color:blue;">New label</span></span>

The first time it work, but second time it doesn’t as explained above. I was trying to find a clean way of doing it without having to put an exception in the code.

Thanks for the help,

ok I now use a different way, but it doesn’t seem to work for checkbox?

    var lObject = document.getElementsByName('nameOfCheckBox');
    if ( lObject[0] && lObject[0].labels ){
        lObject[0].labels[0].style.color= 'red';

it’s something different than the form validate, I want to control the labels colour of my form.