急急急 不知道代码怎么写

mqtheone 2009-10-09 05:27:30
效果如图

点击一个复选框 就在下面的文本框显示,但是 我这个复选框是用服务器控件 (html的控件就不用)
只能用服务器控件写 最后不要刷新啦


html 代码如下
<asp:checkboxlist id="CheckBoxList1" runat="server" RepeatDirection="Horizontal" RepeatColumns="7">
<asp:ListItem Value="电源线">电源线</asp:ListItem>
<asp:ListItem Value="VGA">VGA</asp:ListItem>
<asp:ListItem Value="全配">全配</asp:ListItem>
<asp:ListItem Value="镜头盖">镜头盖</asp:ListItem>
<asp:ListItem Value="提袋">提袋</asp:ListItem>
<asp:ListItem Value="纸箱">纸箱</asp:ListItem>
<asp:ListItem Value="电视盒">电视盒</asp:ListItem>
<asp:ListItem Value="遥控器">遥控器</asp:ListItem>
<asp:ListItem Value="音源线">音源线</asp:ListItem>
<asp:ListItem Value="原箱">原箱</asp:ListItem>
<asp:ListItem Value="保固卡">保固卡</asp:ListItem>
<asp:ListItem Value="AV线">AV线</asp:ListItem>
<asp:ListItem Value="吊架">吊架</asp:ListItem>
<asp:ListItem Value="其它">其它</asp:ListItem>
</asp:checkboxlist>
...全文
134 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
mqtheone 2010-08-23
  • 打赏
  • 举报
回复
test
wuyq11 2009-10-09
  • 打赏
  • 举报
回复
this.CheckBoxList1.Attributes.Add("onclick", "checkv)");
function checkv)
{
var ckelems = document.getElementById("CheckBoxList1").getElementsByTagName("input");
var spelems = document.getElementById("CheckBoxList1").getElementsByTagName("span");

for(var i=0;i<ckelems.length;i++)
{
if(ckelems[i].type=="checkbox")
{
if(ckelems[i].checked)
{
if(strhd.indexOf(spelems[i].value1+",")<0)
hd.value+=spelems[i].value1+",";
}
}
}
Dream_Hunter_ 2009-10-09
  • 打赏
  • 举报
回复
要在checkbox的onclick事件里写判断
sforiz 2009-10-09
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 xuenzhen123 的回复:]
C# codefor (int i=0; i< CheckBoxList1.Items.Count; i++)
{if (CheckBoxList1.Items[i].Selected)
{//输出. }
}
[/Quote]

UP
Dream_Hunter_ 2009-10-09
  • 打赏
  • 举报
回复
JS判断就可以了
chen_ya_ping 2009-10-09
  • 打赏
  • 举报
回复
这个我想就通过JS来搞定
JGood 2009-10-09
  • 打赏
  • 举报
回复
<form id="form1" runat="server">
<div id="div1">
<asp:CheckBoxList ID="CheckBoxList1" runat="server" RepeatDirection="Horizontal"
RepeatColumns="7">
<asp:ListItem Value="电源线">电源线 </asp:ListItem>
<asp:ListItem Value="VGA">VGA </asp:ListItem>
<asp:ListItem Value="全配">全配 </asp:ListItem>
<asp:ListItem Value="镜头盖">镜头盖 </asp:ListItem>
<asp:ListItem Value="提袋">提袋 </asp:ListItem>
<asp:ListItem Value="纸箱">纸箱 </asp:ListItem>
<asp:ListItem Value="电视盒">电视盒 </asp:ListItem>
<asp:ListItem Value="遥控器">遥控器 </asp:ListItem>
<asp:ListItem Value="音源线">音源线 </asp:ListItem>
<asp:ListItem Value="原箱">原箱 </asp:ListItem>
<asp:ListItem Value="保固卡">保固卡 </asp:ListItem>
<asp:ListItem Value="AV线">AV线 </asp:ListItem>
<asp:ListItem Value="吊架">吊架 </asp:ListItem>
<asp:ListItem Value="其它">其它 </asp:ListItem>
</asp:CheckBoxList>
</div>
<div>
<asp:TextBox ID="txt" runat="server" TextMode="MultiLine" Width="200"></asp:TextBox>
</div>
<script type="text/javascript">
function $(o) { return document.getElementById(o); }

function check() {
var str = ''
var inputs = $("div1").getElementsByTagName("input");
for (var i = 0; i < inputs.length; i++) {
if (inputs[i].type == "checkbox") {
if (inputs[i].checked) {
str += ',' + inputs[i].nextSibling.innerHTML;
}
}
}
if (str.length > 0) {
str = str.substring(1, str.length);
}
$("txt").value = str;
}

window.onload = function() {
var inputs = $("div1").getElementsByTagName("input");
for (var i = 0; i < inputs.length; i++) {
if (inputs[i].type == "checkbox") {
inputs[i].onclick = check;
}
}
}

</script>
</form>
ivws_19 2009-10-09
  • 打赏
  • 举报
回复
这个用JS就完全可以了
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 xuenzhen123 的回复:]
C# codefor (int i=0; i< CheckBoxList1.Items.Count; i++)
{if (CheckBoxList1.Items[i].Selected)
{//输出. }
}
[/Quote]
ajax
zjybushiren88888 2009-10-09
  • 打赏
  • 举报
回复
Js遍历Dom对象
xuenzhen123 2009-10-09
  • 打赏
  • 举报
回复

for (int i = 0; i < CheckBoxList1.Items.Count; i++)
{
if (CheckBoxList1.Items[i].Selected)
{
//输出.
}
}
time_is_life 2009-10-09
  • 打赏
  • 举报
回复
http://www.w3schools.com/aspnet/showasp.asp?filename=demo_checkboxlist
playcity 2009-10-09
  • 打赏
  • 举报
回复
客户端javascript.

62,047

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧