I am working on a SharePoint On-Premises 2013 farm. and inside my Create & Edit form, i want to set a Status Choice field as read-only, then later on to chnage its value inside a JavaScript script.
Now i am using SPUtility.js to make my Status field as ReadOnly, as follow:-
SPUtility.GetSPFieldByInternalName('OrderStatus').MakeReadOnly();
But when i try to set its value inside my JavaScript as follow (so when user check a checkbox named “Order Start Working”, to set the Status = “In Progress”):-
$ ('[id^="OrderStartWorking"][id$ ="RadioButtonChoiceField0"]').change(function(){ SPUtility.GetSPFieldByInternalName('OrderStatus').SetValue("In Progress"); });
OR using pure JavaScript appraoch:-
$ ('[id^="OrderStartWorking"][id$ ="RadioButtonChoiceField0"]').change(function(){ $ ('[id^="OrderStatus"]').val("In Progress"); });
the value did not change to “In Progress”
So I am not sure how i can set a value for a read-only choice list OR if i can remove the ReadOnly from my choice list >> then set its value = “In Progress” >> then make it as ReadOnly again. keeping in mind that i do not want to set the Status choice list as disabled using JavaScript, since in this case the value will not get submitted when i save the Edit/Create forms.