How to change the background color of requestor field?

sonbol_montakha
Giga Contributor

When selecting the color from the 'select color ' field, for example if green is selected , the background color of requester field needs to be changed to green. Any thoughts please?

find_real_file.png

1 ACCEPTED SOLUTION

Harsh Vardhan
Giga Patron

Hi Sonbol,



here you go..


i have written onLoad() catalog client script



i have tested and it's working. just change the variable name as per you have deigned.



function onLoad() {


//Type appropriate comment here, and begin script below


var check= g_form.getValue('color');   //"color" is my variable name change as per your variable name


if(check=='green')


{


$('sys_display.'+ g_form.getControl('user').id).style.backgroundColor = 'red';


}


}





find_real_file.png



find_real_file.png



Let me know if you need any further help.


View solution in original post

8 REPLIES 8

karthik120
Giga Expert

Hi Sonbol,



Try with this onchange client script on color field



function onChange(control, oldValue, newValue, isLoading, isTemplate) {



  var a = g_form.getValue('u_choice_1'); // color field value


  var b = document.getElementById('sys_display.incident.caller_id'); // id of the requester field


if(newValue == 'yellow'){


  b.style.backgroundColor = 'yellow';


  }


  if(newValue == 'green'){


  b.style.backgroundColor = 'green';


  }


  if(newValue == 'red'){


  b.style.backgroundColor = 'red';



  }




    //Type appropriate comment here, and begin script below


 


}



Thanks,


Kh


This is my code based on your suggestion , but still not working:



function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
          return;
    }
var a = g_form.getValue('color');


  var b = document.getElementById('req');

if(newValue=='Green')
  {
    b.style.backgroundColor = 'green';
   
    //alert("green");
  }
    else if (newValue=='Red')
      {
        b.style.backgroundColor = 'red';
        // alert("red");
      }
}


and we are not using variable a anywhere in the code right?


Hi Sonbol,



Is it for catalog item variable?



Thanks,


Kh