<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Hello World</title>
</head>
<body>
<div id="navDiv" width="100%" height="50" backgroundColor="#ee5121" >
<div width="100%" height="50" vAlign="middle" hAlign="center" >
</div>
</div>
<div width="100%" height="100%" layout="VBox" overflow="y" >
<div id="privatewv" width="100%" height="725" layout="VBox" >
</div>
</div>
<input type="button" value="获取第一个输入框的值" onClick="getValue1"/>
</body>
<script>
var objArr = [{"title":"商品:水泥","price":"价格:1000元/吨","time":"更新时间:2016-06-05"},
{"title":"商品:钢材","price":"价格:4000元/吨","time":"更新时间:2016-06-04"},
{"title":"商品:煤","price":"价格:3000元/吨","time":"更新时间:2016-06-06"},
{"title":"商品:石油","price":"价格:2000元/吨","time":"更新时间:2016-06-03"},
{"title":"商品:石油2","price":"价格:2300元/吨","time":"更新时间:2016-06-09"}];
paramInfo(objArr);
var paramArr;
function paramInfo(obj) {
paramArr = [];
//在for循环里面动态创建界面控件
for (var i = 0; i < obj.length; i++) {
var privateyield=new Emp.Panel({
"id" : "privateyield",
"width" : "100%",
"height" : "145",
"layout" : "VBox"
});
eval(' title_'+i+' = new Emp.Label({"id" : "title_'+i+'","value" : "'+obj[i].title+ '","fontSize" : "14","marginLeft":"30","height":"30"})');
eval(' price_'+i+' = new Emp.Label({"id" : "price_'+i+'","value" : "'+obj[i].price+ '","fontSize" : "14","marginLeft":"30","height":"30"})');
eval(' time_'+i+' = new Emp.Label({"id" : "time_'+i+'","value" : "'+obj[i].time+ '","fontSize" : "14","marginLeft":"30","height":"30"})');
eval(' text_'+i+' = new Emp.Text({"id" : "text_'+i+'","value" : "","fontSize" : "14","marginLeft":"30","height":"45",width:"200"})');
eval(' line_'+i+' = new Emp.Panel({"height":"1","width":"100%","backgroundColor":"#4A4A4A","marginTop":"9"})');
privateyield.add(eval('title_'+i));
privateyield.add(eval('price_'+i));
privateyield.add(eval('time_'+i));
privateyield.add(eval('text_'+i));
privateyield.add(eval('line_'+i));
privatewv.add(privateyield);
}
}
function getValue1(){
text_0.setValue("sssssss")
alert(eval(text_0).getValue())
}
</script>
</html>
Listview不支持加载输入类控件,动态创建控件去代替listview的示例demo
最新推荐文章于 2024-03-08 17:32:46 发布