Need to make the field readonly

suuriya
Tera Contributor

Hi,

 

I have a requirement, when status is retired or transferred then Hosting information(u_what_type_of_3rd_party_hosting) field need to be read only but I have other requirement so based on that i have written this code.

 

This script will make the field editable based on selecting the value from other field...but now when the status is changed to retired or transferred then the field needs to be readonly.....On top of the script i have added if condition it works (field became readonly) but throwing an error near the on change field.

 

 

 

What is the best way to achieve this.

 

Thanks in advance.

 

1 ACCEPTED SOLUTION

@suuriya change line number 9 and 10 to below 

var status = g_form.getValue('install_status');

if(status!="270")

 

Basically to explain in a simple way you need to use get Value to access some field value on form and you cant write the field name directly like install_status .In your script in line no 9 you directly wrote install_status which script cant recognise as there is no such thing called install status.

But when you change it to above script which i gave ..i used get value and stored it in some variable and used that variable in if statement to compare the value .

 

Hope this helps 

Mark the answer correct if this helps you 

Thanks

View solution in original post

8 REPLIES 8

@suuriya change line number 9 and 10 to below 

var status = g_form.getValue('install_status');

if(status!="270")

 

Basically to explain in a simple way you need to use get Value to access some field value on form and you cant write the field name directly like install_status .In your script in line no 9 you directly wrote install_status which script cant recognise as there is no such thing called install status.

But when you change it to above script which i gave ..i used get value and stored it in some variable and used that variable in if statement to compare the value .

 

Hope this helps 

Mark the answer correct if this helps you 

Thanks

@suuriya Replace line number 9 with the following.

 

var install_status = g_form.getValue('install_status');

 

@suuriya According to the error, in your script you are trying to check a variable install_status using an if which doesn't exist. The screenshot you posted earlier showed install_status line as commented where as from the above error it appears the line if('install_status'!='270' ) is still not commented. 

 

I recommend you to check if the line if('install_status'!='270' ) is commented in your code or not. Also, try clearing the cache of your browser as the client script are usually cached. 

 

Hi @Sandeep Rajput ,

I have added the if condition before because of that error message is showing so now I have commented it.