-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphaseparameter.html
More file actions
165 lines (164 loc) · 6.31 KB
/
phaseparameter.html
File metadata and controls
165 lines (164 loc) · 6.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>相位</title>
<link rel="stylesheet" href="css/index.css">
<link rel="stylesheet" href="css/reasyui.css">
<script src="js/libs/jquery-1.11.2.js"></script>
<script>
//设置行,列
var cols=10; //11列
var rows=8; //16行
var htmlstr="<tr>";
for(i=1;i<=rows;i++){
htmlstr+="<td>"+i+"</td>";
if (i<10) {
i = "0" +i;
};
for(j=1;j<=cols;j++){
if (j<10) {
j = "00" +j;
} else if (j>=10 && j<100) {
j = "0" + j;
} else {
j = j;
}
if (j<=cols-4) {
htmlstr+="<td style='width: 6.3%'>" +
" <div >" +
" <select class='form-control' id="+"s"+i+j+" name="+"s"+i+j+">" +
" <option value='0'>红灯</option>" +
" <option value='1'>绿灯</option>" +
" <option value='2'>绿闪</option>" +
" <option value='3'>黄灯</option>" +
" <option value='4'>黄闪</option>" +
" </select>" +
" </div>" +
" </td>";
htmlstr+="<td style='width: 6.3%'><input class='form-control' type='text' name="+"p"+i+j+" id="+"p"+i+j+"></td>";
} else {
htmlstr+="<td style='width: 6.3%'><input class='form-control' type='text' name="+"p"+i+j+" id="+"p"+i+j+"></td>";
}
}
htmlstr+="</tr>";
}
document.getElementById('phase1').innerHTML = htmlstr;
$.ajax({
url:"/phase1",
type:"POST",
dataType:"json",
success: function(data){
console.log(data);
fillDatas(data.phase1);
}
});
function fillDatas(rect_data) {
$.each(rect_data[0],function(key,item){
$("#"+key+" option[value='']").removeAttr("selected");//2.移除默认选项的选中状态 removeAttr("selected")
$("#"+key+" option[value='"+item+"']").attr("selected","selected");
});
$.each(rect_data[1],function(key,item){
$("#"+key).val(item); //返回结果为null时,转换成空字符串
});
}
function mysubmit()
{
if(window.confirm("确定要提交吗?"))
{
$.ajax({
type: "POST",
url: "/phase1",
contentType: 'application/json',
dataType: "json",
data: $('#form1').serialize(),
success:function(data){
console.log(data);
$.each(data.phase1[0],function(key,item){
$("#"+key+" option[value='']").removeAttr("selected");//2.移除默认选项的选中状态 removeAttr("selected")
$("#"+key+" option[value='"+item+"']").attr("selected","selected");
});
$.each(data.phase1[1],function(key,item){
$("#"+key).val(item); //返回结果为null时,转换成空字符串
});
},
error:function(){
alert("加载资源失败");
}
})
}
else
{
return false;
}
}
function myrst(){
if(window.confirm("确定要重置吗?"))
{
$.ajax({
type: "POST",
url: "/phase1",
contentType: 'application/json',
dataType: "json",
success:function(data){
console.log(data);
$.each(data.phase1[0],function(key,item){
$("#"+key+" option[value='']").removeAttr("selected");//2.移除默认选项的选中状态 removeAttr("selected")
$("#"+key+" option[value='"+item+"']").attr("selected","selected");
});
$.each(data.phase1[1],function(key,item){
$("#"+key).val(item); //返回结果为null时,转换成空字符串
});
},
error:function(){
alert("加载资源失败");
}
})
}
else
{
return false;
}
}
</script>
</head>
<body>
<section class="container-fluid">
<form class="form-horizontal" id="form1" action="#">
<h2 class="legend">相位</h2>
<fieldset>
<div class="col-lg-12">
<table class="table">
<thead>
<tr>
<th >编号</th>
<th >NS1</th>
<th >NT1</th>
<th >NS2</th>
<th >NT2</th>
<th >NS3</th>
<th >NT3</th>
<th >RS1</th>
<th >RT1</th>
<th >RS2</th>
<th >RT2</th>
<th >RS3</th>
<th >RT3</th>
<th >最小绿</th>
<th >最大绿1</th>
<th >最大绿2</th>
<th >延长</th>
</tr>
</thead>
<tbody id="phase1"></tbody>
</table>
</div>
<div class="main-submit">
<button class="btn btn-frist btn-primary" type="button" onclick="mysubmit()">提交</button>
<button class="btn btn-frist btn-primary" type="button" onclick="myrst()">重置</button>
</div>
</fieldset>
</form>
</section>
</body>
</html>