JScript - Disable the field / make the field view-only

Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.

Moderator: amosbatto

Forum rules
Please search to see if a question has already asked before creating a new topic. Please don't post the same question in multiple forums.
fibo2358
Posts: 26
Joined: Wed Nov 16, 2016 6:35 am
Country: Poland

JScript - Disable the field / make the field view-only

Unread postby fibo2358 » Tue Oct 31, 2017 5:54 am

Hello,

I would like to change the "display mode" of a Dynaform field to "disable" or "view" using javascript.
I have tried several combinations like
getFieldById("field_id").disabled = true;
getFieldById("field_id").el.disabled = true;
getFieldById("field_id").readonly = true;
getFieldById("field_id").el.readonly = true;
but nothing works.
Could you please help?

Best Regards,
fibo2358

User avatar
programerboy
Posts: 68
Joined: Mon Aug 28, 2017 4:22 am
Country: Iran
Location: Iran, Mashhad

Re: JScript - Disable the field / make the field view-only

Unread postby programerboy » Tue Oct 31, 2017 6:50 am

Hi,

You can use like this:

Code: Select all

$("#textVar001").getControl().attr('disabled', true);


Thanks

amosbatto
Posts: 5564
Joined: Mon Jun 22, 2009 10:28 am
Country: Bolivia
Location: La Paz

Re: JScript - Disable the field / make the field view-only

Unread postby amosbatto » Tue Oct 31, 2017 9:35 pm

You can also use for text and textarea fields:
$("#fieldID").getControl().prop("readonly", true)
Amos B. Batto ♦ ProcessMaker Technical Documentation Writer & Forum Manager ♦ Cofounder of ILLA (http://www.illa-a.org)

fibo2358
Posts: 26
Joined: Wed Nov 16, 2016 6:35 am
Country: Poland

Re: JScript - Disable the field / make the field view-only

Unread postby fibo2358 » Mon Nov 06, 2017 8:32 am

Hello,

Thank you for the answers. I have applied the first solution and it works OK.

Best Regards,
fibo2358


Return to “Developing processes & programming”

Who is online

Users browsing this forum: No registered users and 3 guests