Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to increase text field width?

Wirasat
Tera Guru

I have a text field of string type. I am trying to increase its width to 300px using onLoad client script. But, its not working. I tried it in field style option as well but didn't work either.

g_form.getControl('email_address').style.width = '300px';

However, other properties in the same script works fine .

g_form.getControl('email_address').style.backgroundColor = 'yellow';
g_form.getControl('email_address').style.color = 'blue';

1 ACCEPTED SOLUTION

RatneshTSN
Giga Guru

Hi Wirasat,

 

You can try with field style; its working for me. See the screenshot below

For this you need to configure style against this field in field style

Type Field style in application navigator; configure against your table-field.  Let me know if it still does not work and if it works mark this as helpful. 

e.g. like this.

find_real_file.png

find_real_file.png

 

View solution in original post

10 REPLIES 10

Bhawana Upreti
Tera Guru

Hi, Can you please try the below script once.

function onLoad() {
   //Set styles for the 'email_address' variable
   var myVar = $('sys_display.' + g_form.getControl('email_address').id);
   myVar.style.width = '350px';
   myVar.style.backgroundColor = 'yellow';
   myVar.style.color = 'blue';
   myVar.style.fontStyle = 'italic';
   myVar.style.fontWeight = 'bold';
}

 

Thanks.

Did not work.

Wirasat,

Can you please provide your code.

Thanks.

Are you working on Catalog client script or its just a simple client script ??

Thanks.