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

Hi Sagar and Midhun,


        Thanks for the input. But I would like the text to change depending on the font the user chooses.This can be done only though code i guess.



Thanks,


Sam


Yes Sam, it is because i feel you have put the element id with a wrong value.



To get the element id of any field follow the below steps



1. Press F12 while opening your browser


2. Press the search icon in the browser console and hover over the element or the field which you want to change


3. You will see an id in the html code, just copy the id


4. Then use the code below



gel('<element id(to be replaced with the original id)>').style.font-family=g_form.getValue('u_font_style');


Hi arka,


            I am still not clear on how to get the element id.When i press F12 in my laptop i get the option of keeping the wireless on or off. And I dont understand the below statement.


          Press the search icon in the browser console and hover over the element or the field which you want to change.




Thanks,


Sam


To get that right click on the page and then click on Inspect or Inspect Element.


tanumoy
Tera Guru

Use val.style.font-family= "g_form.getValue('u_font_style')"; instead of val.style.fontFamily= g_form.getValue('u_font_style');