How to save single value from a select field? I have webform module with multiselect field (Checkbox) User can select all the three.


  PR|Print Required
  DP|Digital Print Required
  TP|Print has been taken


If user selects the last option then, only that option must be saved after submitting even if the other options are selected. If other two options are selected then as usual those options should be saved.

In General,
If the user selects the first two options, it should accept the first two options. If user selects third option, then it should save the third option not other two options(If user selects). Example: If user selects all three options, then it should save only the last option.If user selects the last option i.e., Print has been taken, then it should save that irrespective of other selections.
I would use jQuery to deactivate and uncheck the other two checkboxes when the third has been checked. If they uncheck the third, they will all become active.

Your Drupal form will look something like this:

&lt;div class="form-checkboxes" id="edit-field-terms-und"&gt;
&lt;div class="form-item form-type-checkbox form-item-field-terms-und-pr"&gt;
    &lt;input type="checkbox" class="form-checkbox" value="pr" name="field_terms[und][pr]" id="edit-field-terms-und-pr"&gt;  &lt;label for="edit-field-terms-und-pr" class="option"&gt;Print Required&lt;/label&gt;
&lt;/div&gt;
&lt;div class="form-item form-type-checkbox form-item-field-terms-und-dp"&gt;
    &lt;input type="checkbox" class="form-checkbox" value="dp" name="field_terms[und][dp]" id="edit-field-terms-und-dp"&gt;  &lt;label for="edit-field-terms-und-dp" class="option"&gt;Digital Print Required&lt;/label&gt;
&lt;/div&gt;
&lt;div class="form-item form-type-checkbox form-item-field-terms-und-tp"&gt;
    &lt;input type="checkbox" class="form-checkbox" value="tp" name="field_terms[und][tp]" id="edit-field-terms-und-tp"&gt;  &lt;label for="edit-field-terms-und-tp" class="option"&gt;Print has been taken&lt;/label&gt;
&lt;/div&gt;
&lt;/div&gt;


jQuery code would be something like this:

(function($) {
$(document).ready(function() { 

    $("#edit-field-terms-und-tp").click(function() {
        if($(this).is(':checked')) { 
            $('#edit-field-terms-und-pr, #edit-field-terms-und-dp').attr('disabled', true).prop('checked', false );
        } else {
            $('#edit-field-terms-und-pr, #edit-field-terms-und-dp').removeAttr('disabled');
        }
    });

});
})(jQuery);


Haven't tested it, but it should work.