SharePoint 2013 edit form - read-only choice field reverting to first item on save

Phillips, Keith 701 Reputation points
2021-07-27T15:27:27.557+00:00

I have a custom edit form for a SharePoint 2013 list; it contains JS code that sets all but two of the fields to readonly. When the form is opened and saved, the existing values for all of the choice fields change to the first item in each choice list, which was not intended.

Here's my JS code if you're interested:

$(document).ready(function() {
    jQuery("input[title^='Server Name']").prop("readonly", true);

    jQuery("select[title^='Server Type']").attr("disabled","true").css('color','#000000');
    jQuery("select[title^='Site']").attr("disabled","true").css('color','#000000');
    jQuery("select[title^='Operating System']").attr("disabled","true").css('color','#000000');
    jQuery("select[title^='Replace Existing Server']").attr("disabled","true").css('color','#000000');

    jQuery("input[title^='Current Server Name']").prop("readonly", true);

    jQuery("select[title^='File Server']").attr("disabled","true").css('color','#000000');
    jQuery("select[title^='Print Server']").attr("disabled","true").css('color','#000000');
    jQuery("select[title^='VPN Required']").attr("disabled","true").css('color','#000000');
    jQuery("select[title^='Pre-Build Status']").attr("disabled","true").css('color','#000000');
});

My google-fu is failing me today - I just can't find a solution. Help!

SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
2,617 questions
0 comments No comments
{count} votes

1 additional answer

Sort by: Most helpful
  1. RaytheonXie_MSFT 30,186 Reputation points Microsoft Vendor
    2021-07-28T07:47:38.84+00:00

    Hi @Phillips, Keith ,
    Per my test, I found that the script runs well.
    I edit the item which title is 1234
    118576-image.png
    I get following form,and the choice column is not the first item in its list
    118537-image.png
    After saving the data doesn't change too.
    We might need more details to test the exception.


    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.