Changing the font style

coolgirl
Mega Expert

Hello,

            I would like to know how to change the font style of selected field. I have written the below code in on change of 'font style' field (it has list of font styles), which does not seem to work.

function onChange() {

  var val = g_form.getValue('u_text');

  val.style.fontFamily= g_form.getValue('u_font_style');

}

Thanks,

Sam

1 ACCEPTED SOLUTION

OK... then use var style1 = g_form.getDisplayBox('u_font_style').value; instead of var style1 = g_form.getValue('u_font_style');




View solution in original post

13 REPLIES 13

ark6
Mega Guru

I feel you need to use gel for this one



1. Get the id of the field through developer tools in the browser


2. gel('<element id>').style.font-family=g_form.getValue('u_font_style');



Please mark the answer as helpful if found appropriate


Hi Arka,


          I am getting the following error message 'Cannot read property style of null function'



Thanks,


Sam


Midhun1
Giga Guru

Hi Sam,



If you want to create it permanently then :


Defining Field Styles - ServiceNow Wiki


sagaragarwal1
Giga Contributor

Hi Sam,


If you want to define style for individual fields on form view or list view, you can refer to below method.



Go to System UI > Field styles > new



Select the table on which concerned field(s) exist. select the field.


After this you can define the style by providing CSS properties.



For more info refer to Defining field styles : Geneva