Home  >  Article  >  Backend Development  >  关于下拉列表绑定的小疑点

关于下拉列表绑定的小疑点

WBOY
WBOYOriginal
2016-06-13 12:04:561020browse

关于下拉列表绑定的小问题
在 php 中
$redata=array();
$redata[-2]='CPU';
$redata[-3]='操作系统';
$redata[-4]='尺寸';
foreach ($temp as $key=>$value){
$redata[$value['id']]= id2name('prodcut_conf_type',$value['conf_type']);
}
最后得到的结果
"-2":"CPU","-3":"\u64cd\u4f5c\u7cfb\u7edf","-4":"\u5c3a\u5bf8","1":"\u786c\u76d8"
由于编码问题。中文没有显示,这个没问题
翻译过来是:"-2":"CPU","-3":"操作系统","-4":"尺寸","1":"硬盘"

硬盘是从数据库表中读出来的

然后是html
$.post('{:U('Product/getTypeToMenuJson')}',{ptype:$("#mid").val()},function(data) {
     var option = $("

<br />d = data.data;<br />for(var i=0; i<d.length; i++){<br />  var option = $("<option>").text(d[i][1]).val(d[i][1])<br />    menudroplist.append(option);<br />}<br />

------解决方案--------------------
{"data":[["-2","CPU"],["-3","\u64cd\u4f5c\u7cfb\u7edf"],["-4","\u5c3a\u5bf8"],["1","\u786c\u76d8"]],"info":"","status":1}

------解决方案--------------------

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn