1

I have a dropdown in an edit form that is disabled via jquery/javascript. When I go in and edit an item/record, save it, and reopen it, the selected value in the dropdown gets reset to its default value. When I remove the javascript that is disabling the control, the values don't get reset. The drop down only has two values; open and closed. he default is open. Here is the javascript:

$(function() {
        $("select[title$='Procurement Stage']").attr('disabled', 'disabled');
}
2

The field has to be enabled prior to submission, typically via the PreSaveAction function.

Marc has it demonstrated here, I swapped in your code:

$(document).ready(function() {
        $("select[title$='Procurement Stage']").attr('disabled', 'disabled'); 
    });

    function PreSaveAction() {
        $("select[title$='Procurement Stage']").attr('disabled', ''); 
        return true;
    }
0

I used the below line in my PreSaveAction() but still the drop-down doesn't get enabled.

$("select[title$='Status']").attr('disabled', ''); 

But the below line is making the status disable properly:

$(document).ready(function() {
        $("select[title$='Status']").attr('disabled', 'disabled'); 
    });
0

This is what i ended up doing. I wrote my custom function that converts value of select element to text. No issues with posting back to the server this way.

$(document).ready(function()
 {
       var el= $("select[title$='Status']");
       ConvertToText(el);
 });

function ConvertToText(element)
 {
    var txtHTML = element.val();
    var tdColumn = element.closest('td');
    var tdColumnHTML = $(tdColumn).html();
    $(tdColumn).html("<div style='display:none'>'" + tdColumnHTML +  "'</div>");
    $(tdColumn).append(txtHTML);
 }  

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.