Jump to content

Dynamic drop down in HTML


aneeb

Recommended Posts

Hey everyone! i am creating a dynamic drop down menu in html, but the values are not coming in the drop down, it shows an empty menu. I am calling the PHP file which is echoing JSON of the data. here is the Javascript code..

$(function(){var serviceURL = "http://localhost/mano-2/";var get = '';  get = 'echo_cat.php';  var items="";  $.getJSON(serviceURL + get , function(data){	$.each(data,function(index,item)	{	  items = items + "<option value='"+item.entity_id+"'>"+item.name+"</option>" ;	});	$("#a1_title").html(items);  });}); 

the JSON is like this

{"items":[{"entity_id":"1","name":"Root Catalog"},{"entity_id":"2","name":"Default Category"}]}

the HTML code is like this

<select id="a1_title">  <option>Default</option></select>

Please help me..

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...