SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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');
}
share|improve this question

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;
    }
share|improve this answer
    
Got it. I also found this: jbmurphy.com/2010/06/01/… I guess disabled controls don't get thier values posted. Thanks. – Steve Jun 11 '12 at 20:23

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'); 
    });
share|improve this answer

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);
 }  
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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