简体   繁体   中英

Cannot get disabled drop down field values by jQuery serialize method using Angular.js/JavaScript

I need to fetch the selected data from the drop down list which is disabled using jQuery/Angular.js:

<div class="input-group bmargindiv1 col-md-12">
     <span class="input-group-addon ndrftextwidth text-right" style="width:180px">Status :</span>
    <select class="form-control" name="status"  id="status" ng-model="status"  ng-change="removeGSTValue('status');" disabled="disabled" >
                                     <option value="">Select Status</option>
     <option value="1">Active</option>
    <option value="0">Inavtive</option>
     </select>
    </div>

One value has already selected and this field is disable one can view it can not change. I have to fetch the pre selected but it's not happening like that using jQuery serialize method. When I am using readonly the drop down value is changing.

You will want to use the readonly attribute and not disabled.

You could do a bunch of workarounds like using a non disabled hidden field to pass a value to jQuery serialize but just use the right HTML attribute and you'll be fine.

Also, you don't need jQuery serialize. Use a prefix to your ng-model like formData.status instead of status . Submit that formData value in your http request or just use JSON.stringify(formData) .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM