javascript - How to add option/ ListItem to dropdownlist dynamically -


I need to dynamically create my DDL, I get use of JSON from DSB (I any I do not get the problem ) but could not show my data in my DDL ... I tried three different ways, nothing is changing. What am I doing?

// HTML

  and ATP: dropdown list id = "product ddl" runat = "server" css class = "ddl" & gt; & Lt; / Asp: dropdownlists & gt;  

// javascript

  function creatDDL (data) {var obj = $ .parseJSON (data.Data); (Var i = 0; i & lt; obj.length; i ++) {$ ("# Product DDL") for Attachments ("& lt; Option & gt;" + obj [i] .ID + "'-'" + + obj [i] .name + "& lt; / option & gt;"); $ ("# ProductDDL"). Attachments ("& lt; Option & gt;" + obj [i] .ID + "'-'" + obj [i] .name + "& lt; / Options & gt;"); $ ("# ProductDDL") .andend ($ ("

I like your third attempt in order to handle your data, You just need to brush.

Here's a working version of what I'm trying to collect:

function createDDL (data) {var options = $ .parseJSON (data.Data ); $ .elect (option, function (n, option) {var $ option = $ ('& lt; option />').text(option.name).val(option.id); $ ("# productDDL" ) .append ($ option);}); }

Object:


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -