jquery - not able to set selected value for Html.Dropdown list -


i trying set selected value (value returned json result) html.dropdownlist. dropdown list has value. instance :json returned value:abc ,this value there in ddl

jquery

   $("#action").each(function (state) {      if (this.value == state.value)     {             var thetext=state.value;       $('#action').val(thetext); //i think not suppose     }); 

the if condition satisfies when try set value nothing happens

ddl

  @html.dropdownlist("action", viewbag.actdict_action selectlist) 

what trying ddl (id:action)displays value json has retuned along other values .

any appreciated . ..

in ddl in view bag, list right? assuming array of things this:

new selectlistitem{text="deactive", value="false"} 

for 1 want selected, initialize before passing through viewbag

new selectlistitem{text="deactive", value="false", selected="true"} 

Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -