如何计算所选复选框的总计?
我正在使用带有母版页的 ASP.NET。在其中我有一个嵌套的转发器:
<asp:Repeater ID=rptAttribute runat=server>
<ItemTemplate>
<h3><%# DataBinder.Eval(Container.DataItem, "Description") %></h3>
<div id="labelbox">
<asp:TextBox ID="tSecionTotal" runat="server"></asp:TextBox>
<div id="key1">
<asp:Repeater ID="rptKey" runat="server">
<ItemTemplate>
<asp:CheckBox ID="rptKeySelection" runat="server" />
<span><%# DataBinder.Eval(Container.DataItem, "Description") %></span>
</ItemTemplate>
</asp:Repeater>
</div>
</ItemTemplate>
</asp:Repeater>
我想计算每个部分中复选框的值并进行两个显示。
- 使用复选框中的值更新文本框字段 (tSecionTotal)。
- 更新总文本/标签的总和。
呈现的 HTML 看起来像这样:
适当地打开和关闭交互
[ -- 显示本节总计的文本框 -- ][]尚未准备好进行互动 [+1]
[]没有使用正确的打开方式 [+1]
[]不保证没有其他需求[+2]
[]没有以适当的方式关闭交互[+5]>
表现出共同的礼貌(礼貌、耐心、同理心)
[ -- 显示本节总计的文本框 -- ][]没有使用常见的礼貌用语(请,谢谢)[+1]
[]对客户的语气/语调变化不恰当 [+2]
[]不当打断客户 [+5]
[]在需要时没有表现出同理心 [+2]适应客户的知识和专业水平
[ -- 显示本节总计的文本框 -- ][]没有提供明确的说明(如何做)[+1]
[]没有提供明确的说明(如何)[+1]
[]没有提供明确的解释/教育(我们为什么这样做)[+3]
[]没有提供明确的解释/教育(我们为什么这样做)[+5]总体总计 [ -- 显示总体总计的文本框 -- ]
I am using ASP.NET with a masterpage. Within it I have a nested repeater:
<asp:Repeater ID=rptAttribute runat=server>
<ItemTemplate>
<h3><%# DataBinder.Eval(Container.DataItem, "Description") %></h3>
<div id="labelbox">
<asp:TextBox ID="tSecionTotal" runat="server"></asp:TextBox>
<div id="key1">
<asp:Repeater ID="rptKey" runat="server">
<ItemTemplate>
<asp:CheckBox ID="rptKeySelection" runat="server" />
<span><%# DataBinder.Eval(Container.DataItem, "Description") %></span>
</ItemTemplate>
</asp:Repeater>
</div>
</ItemTemplate>
</asp:Repeater>
I am wanting to calculate the values of the checkboxes within EACH section and make two displays.
- Have the textbox field (tSecionTotal) update with the value(s) from the checkboxes.
- Have an total text/label update with an overall total.
HTML rendered looks something like this:
Opened and closed the interaction appropriately
[ -- textbox to display total of this section -- ][]Was not ready to take the interaction [+1]
[]Did not use proper opening [+1]
[]Did not ensure that there were no other needs [+2]
[]Did not close the interaction in an appropriate manner [+5]>Demonstrated common courtesy (polite, patient, empathetic)
[ -- textbox to display total of this section -- ][]Did not use common courteously words (please, thank you) [+1]
[]Inappropriate voice level / inflection with customer [+2]
[]Inappropriately interrupts customer [+5]
[]Did not demonstrate empathy when needed [+2]Adapted to the customer's level of knowledge and expertise
[ -- textbox to display total of this section -- ]
[]Did not provide clear instructions (how to) [+1]
[]Did not provide clear instructions (how to) [+1]
[]Did not provide clear explanation / education (why we are doing this) [+3]
[]Did not provide clear explanation / education (why we are doing this) [+5]Overall Totals [ -- textbox to display overall total -- ]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以找到所有选中的项目,然后找到项目的值,添加它们并将其放在总计中
我在这里所做的是找到所有复选框,然后对于每个复选框,我都会找到其元素(例如
class=keydiv
),然后我在 tr 的子元素中发现了具有您要添加的值的元素,我想它具有 css="myVal"。假设你像这样渲染它。
You can find all checked, then the values of the items, add them and place it on total
What I do here is to find all check box, then for each check box I go to find the souround it element (eg the
class=keydiv
), then I found inside the children of tr the element that have the value you won to add, I suppose that have the css="myVal".Let say that if you render it like that.