How I can display dropdown menu list based on my JSON response object?

General discussions related to php

Moderators: egami, macek, gesf

Post Reply
New php-forum User
New php-forum User
Posts: 16
Joined: Sun Sep 11, 2016 8:38 am

Sat Aug 29, 2020 6:04 pm

I am trying to display a dropdown list based on JSON response object, How I can set it for the following code?

in html

Code: Select all

<select class="form-control" name="productCategories[]" id="productCategories<?php echo $x; ?>" onchange="getProductData(<?php echo $x; ?>)" >
in javascript

Code: Select all

				url: 'php_action/fetchDropdownProductData.php',
				type: 'post',
				data: {brandId : brandId},
				dataType: 'json',
				success:function(response) { 
			var html = '<option value="">Select Sub Category</option>';
            html += response;
				} // /success
Post Reply