javascript - Show AJAX success JSON values in html selection -


i have html form few drop down selections, used same form editing data,

now edit data in row of table, had created ajax request, once row selected , user click on edit, ajax values of specific row id.

my html form have input elements , select element, can show value in input element below code,

in html element id - user_name input type, can see data value in box,

but element id - user_status selection type, have options enable , disable,

      success:function(data){            var objdata = jquery.parsejson(data);                    $("#user_name").val(objdata.user_name);         $("#user_status").val(objdata.user_status);       } 

this html select code,

  <select name="is_manager" id="user_status">       <option style="width:auto">--select status--?</option>       <option style="width:auto">enable</option>       <option style="width:auto">disable</option>   </select> 

how can show ajax return value enable in selection option when click edit row, in short want see existing value in selection element.

thanks,

added option value in below selection list same option text

<select name="is_manager" id="user_status"> <option style="width:auto" value="">--select status--?</option> <option style="width:auto" value="enable">enable</option> <option style="width:auto" value="disable">disable</option> </select>

and in jquery can use below code set existing value selected

$("#user_status option[value="+objdata.user_status+"]").attr("selected","selected")

hope helps you


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -

ios - Possible to get UIButton sizeThatFits to work? -