1 <script language=javascript> 2 function IdentifyRepair(event_id) 3 { 4 var url; 5 url = "/View/faultyinfo?event_id=" + event_id; 6 window.location.href = url; 7 } 8 9 function GetEventId() 10 { 11 var evid_list = document.getElementsByName("evid_list"); 12 var evid_info = ""; 13 for(var j=0; j<evid_list.length; j++){ 14 evid_info += evid_list[j].value + " "; 15 } 16 17 var url; 18 url = "/View/faultyinfo?event_id=" + evid_info; 19 window.location.href = url; 20 } 21 </script> 22 23 <body> 24 25 <table class=title width=700> 26 <tr> 27 <td><b>故障信息</b></td> 28 <td style="font-size:12px;color:#185A73" align=right width=*>{% module Uptime() %}</td> 29 </tr> 30 </table> 31 32 <br> 33 {% if lists != [] %} 34 <input type="button" onclick="GetEventId()" value="repair all"> 35 {% end %} 36 <br> 37 {% for d in lists %} 38 <table width=900 border=0 cellspacing=1 cellpadding=1> 39 <tr id=tblhdr height=22> 40 <td width=200 align=center>TIME</td> 41 <td width=300 align=center>EVENT_ID</td> 42 <td width=150 align=center>MSG_ID</td> 43 <td width=150 align=center>SEVERITY</td> 44 <td align=center> 45 {% if d['event_id'] %} 46 <a style="color:#0000ff" 47 href="javascript:IdentifyRepair('{{d['event_id']}}')">修复</a> 48 {% end %} 49 </td> 50 </tr> 51 52 <tr id=row1> 53 <td align=center>{{ d['time'] }}</td> 54 <td align=center>{{ d['event_id'] }}</td> 55 <td align=center>{{ d['msg_id'] }}</td> 56 <td align=center>{{ d['severity'] }}</td> 57 <input name="evid_list" type="hidden" value={{ d['event_id'] }} /> 58 59 </tr>
通过 57 行代码,每次执行该行代码将 event_id 存放到 input name="evid_list" 中
通过 34 行代码,点击button按钮,执行JS代码 GetEventId() ,将所有的event_id存放到变量 evid_info 中,最后传递到后台