- 注册时间
- 2019-3-3
- 最后登录
- 2021-12-25
- 阅读权限
- 10
- 积分
- 19
- 精华
- 0
- 帖子
- 3
|
我希望做一个动态表单,控件动态产生,并render到form中,但是提交订单的时候,发现打印出来的data是空白的,我尝试过把动态的表单改成静态的界面,提交时候是可以获取到表单数据的,以证明获取方法是没有问题。请问我需要怎么在动态表单里获取对应的控制值?谢谢。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<link href="demo/demo.css" rel="stylesheet" type="text/css" />
<script src="scripts/boot.js" type="text/javascript"></script>
<style>
.mini-labelfield-label
{
width:100px;
}
body .mini-labelfield
{
width:250px;
margin:0;
margin-top:10px;
font-size: 20px;
}
</style>
</head>
<body>
<div id="form1">
</div>
<script type="text/javascript">
mini.parse();
function onClick(){
var form = new mini.Form("#form1");
// form.validate();
// if (form.isValid() == false) return;
//提交数据
var data = form.getData();
var json = mini.encode(data);
console.log(data);
}
function initFieldsFromSpecificFields(){
var form1 = $("#form1")[0];
var textbox = new mini.TextBox();
textbox.set({
id:"text",
value:"bb",
label:"textbox",
class:"mini-textbox",
labelField:true,
required:true
// borderStyle: "border:1px solid red"
});
textbox.render(form1);
var combo = new mini.ComboBox();
combo.set({
id:"combobox",
labelField:true,
label:"测试",
url:"data/combobox_data_source.txt",
multiSelect:false,
value:"1"
});
combo.render(form1);
var submitButton = new mini.Button();
submitButton.set({
"text":"OK",
"class":"mini-button",
"iconCls":"icon-add",
"onclick":"onClick",
"tooltip":"Submit"
});
submitButton.render(form1);
}
initFieldsFromSpecificFields();
</script>
</body>
</html>
|
|