日期:2014-05-16 浏览次数:20838 次
//html代码
<script type="text/javascript">
$(document).ready(function(){
getSelectVal($("#smallname"));
});
</script>
<label>设备: </label>
<select name="smallname" id="smallname">
</select>
//js 代码,
function getSelectVal(name){
$.get("cpureport.php",function(data){
alert(data);
//cpureport.php 产生的数据
[{"id":"184351832"}]
<html>
<head>
<title></title>
<script type="text/javascript" src="jquery-1.9.1.min.js"></script>
<script>
$(function () {
var data = [
{id:"a"},
{id:"b"},
{id:"c"}
];
for(var i in data){
$('#test').append("<option id='"+data[i].id+"'>"+data[i].id+"</option>")
}
})
</script>
</head>
<body>
<select id="test">
</select>
</body>
</html>