checkboxlist 下拉框多选功能 ,模拟dropdownlist带复选框效果
前台代码
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 | 01.<html xmlns= "http://www.w3.org/1999/xhtml" > 02.<head runat= "server" > 03. <title>下拉框实现多选</title> 04. <script src= "Jquery-1.8.3.min.js" type= "text/javascript" ></script> 05. <script type= "text/javascript" > 06. /* 07. * 08. * 09. */ 10. $(function() { 11. $( "#<%=txtList.ClientID %>" ).mouseenter(function() { 12. $( "#divChkList" ).slideDown( "fast" ); 13. }); 14. $( "#divMulti" ).mouseleave(function() { 15. $( "#divChkList" ).slideUp( "fast" ); 16. }); 17. $( "#divChkList :checkbox" ).each(function() { 18. $( this ).click(function() { 19. var $txtList = $( "#<%=txtList.ClientID %>" ); 20. if ( this . checked ) { 21. $txtList.val($txtList.val() + $( this ).next().text()+ "," ); 22. } 23. else { 24. $txtList.val($txtList[0].value.replace($( this ).next().text()+ ',' , '' )); 25. } 26. }); 27. }); 28. }); 29. </script> 30. 31.</head> 32.<body> 33. <form id= "form1" runat= "server" > 34. <input type= "checkbox" id= "test" value= "1" title= "d" /> 35. <div style= "width:400px;height:300px;margin:0 auto;" > 36. <div id= "divMulti" > 37. <asp:TextBox ID= "txtList" runat= "server" Width= "100px" ></asp:TextBox> 38. <div id= "divChkList" style="display: none; border: solid 1px #CCCCCC; position: fixed ; 39. z-index: 100; height: 160px; width: 100px; overflow-y: scroll; background-color: White"> 40. <asp:CheckBoxList ID= "chkList" runat= "server" RepeatLayout= "Table" RepeatDirection= "Vertical" > <br> <asp:ListItem Value= "12036" >(12036)汉庭星空酒店管理有限公司</asp:ListItem><br> <asp:ListItem Value= "12036" >(12036)汉庭星空酒店管理有限公司</asp:ListItem><br> <asp:ListItem Value= "12036" >(12036)汉庭星空酒店管理有限公司</asp:ListItem><br> <asp:ListItem Value= "12036" >(12036)汉庭星空酒店管理有限公司</asp:ListItem><br> <asp:ListItem Value= "12036" >(12036)汉庭星空酒店管理有限公司</asp:ListItem><br> <asp:ListItem Value= "12036" >(12036)汉庭星空酒店管理有限公司</asp:ListItem> 41. </asp:CheckBoxList> 42. </div> 43. </div> 44. </div> 45. </form> 46.</body> 47.</html> |
分类:
ASP.NET(C#)
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· .NET10 - 预览版1新功能体验(一)