function ChuanZhi(zhi) { var bian = document.getElementById("bian").value; if (bian.toString() == "") { bian = zhi; } document.getElementById(bian).style.backgroundColor = "#66CCFF"; document.getElementById(bian).style.color = "#000000"; document.getElementById("FuZhi").value = zhi; document.getElementById("bian").value = zhi; document.getElementById(zhi).style.backgroundColor = "#0066CC"; document.getElementById(zhi).style.color = "#FFFFFF"; }
<asp:DataList ID="DataList1" runat="server" RepeatDirection="Horizontal" RepeatColumns="7" Height="31px"> <ItemTemplate> <div id="<%#Eval("id") %>" onclick="ChuanZhi(<%#Eval("id") %>)" style=" 80px; height: 30px; line-height:30px; text-align: center; background-color: #66CCFF"> <%#Eval("ZhongWenMing")%> </div> </ItemTemplate> </asp:DataList>
<input type="hidden" id="bian" /> <input type="hidden" id="zhoushu" />