81,092
社区成员
发帖
与我相关
我的任务
分享
Class A {
String name;
City city; //City是一个单独的类,它也有自己的一些字段
Brand brand; //Brand 同理也有是一个单独的类,也有自己的一些字段
}
//查询返回处理函数
function productCallBack(productList) {
var code;
var model;
var brand;
var city;
var province;
var type;
var color;
//循环集合,得到box
for(var property in productList){
//循环box,判断字段
for(var pro in productList[property]){
//如果字段为productInfo则进一步循环productInfo
if(pro == "productInfo"){
for(var pro3 in productList[property][pro]) {
if(pro3 == "code") {
code = productList[property][pro][pro3];
}else if(pro3 =="type") {
for(var pro4 in productList[property][pro][pro3]) {
if(pro4 == "name") {
type = productList[property][pro][pro3][pro4];
}
}
}else if(pro3 == "model") {
model = productList[property][pro][pro3];Js代码
//如果字段为brand,则再一步循环brand,已便得出brand下的所有字段
}else if(pro3 == "brand") {
for(var pro4 in productList[property][pro][pro3]) {
if(pro4 == "name") {
brand = productList[property][pro][pro3][pro4];
}
}
}else if(pro3 == "color") {
for(var pro4 in productList[property][pro][pro3]) {
if(pro4 == "name") {
color = productList[property][pro][pro3][pro4];
}
}
}
}
}
}
}
alert(code);
alert(type);
alert(model);
alert(brand);
alert(color);
}
function getFenleiByXilieId(date){
var html="<span class='select1'><select style='width:105' name='fenlei'>";
var html3="</select></span>"
var html2="<option value=\"\">所有分类</option>";
for(var i=0;i<date.length;i++)
{
if('${param.fenlei}'==date[i].id)
{
html2+="<option value="+date[i].id+" selected>"+date[i].fenleiname+"</option>";
}
else{
html2+="<option value="+date[i].id+">"+date[i].fenleiname+"</option>";
}
}
document.getElementById("fenlei").innerHTML=html+html2+html3;
}