我的结果如下。(标识和价值)
{"5702":"7am - 10am","5703":"10am - 1pm","5704":"12pm - 3pm","5705":"3pm - 6pm","5706":"6pm - 9pm" ,"5707":"7pm - 10pm","5708":"9pm - 12am","5709":"12am - 7am","5730":"AZRAAR 123"}
这被采取如下。
JSON.stringify(<?php echo $timeWindowJson ?>)
现在我有这个附加虚拟下拉。
var array = selectedDates.split(",");
var dynamicTable = "<table id='tbl_dynamic_call_dates'><tr><td>Appointment date</td><td>Client time window</td>";
$.each(array, function(i) {
dynamicTable += "<tr><td>" + array[i] + "</td><td>" + "<select><option value='volvo'>7am - 10am</option></select>" + "</td></tr>";
});
dynamicTable += "</table>";
$("#div_outgoing_call_dates_rows").append(dynamicTable);
但我希望附加的下拉列表是这样的。
<select name="CSSAtapsClient[gender_type_id]" class="long" id="gender_type_id">
<option value="">- - Select Gender - -</option>
<option value="5702">7am - 10am</option>
<option value="5703">10am - 1pm</option>
<option value="5704">12pm - 3pm</option>
......(直到所有的值都从 json 字符串中添加)