JQuery 循环遍历复选框并填充 div
<div id="termSheetPopup">
<input type="checkbox" name="SummaryInformation">Summary Information<br />
<input type="checkbox" name="SwapLegs">Swap Legs<br />
<input type="checkbox" name="AmortizationOptions">Amortization Options<br />
<input type="checkbox" name="EconomicResults">Economic Results<br />
<input type="checkbox" name="AmortizationSchedule">Amortization Schedule
</div>
<div id="printing">
</div>
因此,查看上面的代码,termSheetPopup
是我转入 JQuery 对话框的 div。当用户单击对话框“生成”按钮时,我希望 JQuery 告诉我所有选中的复选框的名称(其中的 name
元素),以便我可以使用这些名称来填充div 打印
。这些名称中的每一个都对应于我想要在 div 中渲染的部分视图。
另外,如果您有时间,我将如何使用 JQuery 动态呈现部分视图,类似于我在 ASP.NET 页面上的做法,如下所示:
<% Html.RenderPartial("~/Views/Indications/AmortizationSchedule.aspx", Model.Trx); %>
How can I do this?
谢谢!
<div id="termSheetPopup">
<input type="checkbox" name="SummaryInformation">Summary Information<br />
<input type="checkbox" name="SwapLegs">Swap Legs<br />
<input type="checkbox" name="AmortizationOptions">Amortization Options<br />
<input type="checkbox" name="EconomicResults">Economic Results<br />
<input type="checkbox" name="AmortizationSchedule">Amortization Schedule
</div>
<div id="printing">
</div>
So looking at the above code, the termSheetPopup
is the div that I turn into my JQuery dialog. When the user clicks the dialog 'Generate' button, I want JQuery to tell me the names of all of the checkboxes that are checked (the name
element of them), so I can use those names to populate the div printing
. Each of those names correspond to a partial view that I want to render within the div.
Also, if you have time, how would I render a partial view dynamically using JQuery, similar to how I do it on the page within ASP.NET like this:
<% Html.RenderPartial("~/Views/Indications/AmortizationSchedule.aspx", Model.Trx); %>
How could I do this?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
应该有帮助。对每个循环、数组中的名称执行您需要的操作,附加到 div 等...
编辑: 为完整性进行编辑,将名称附加到以逗号分隔的打印 div 中。也应该将其放入准备好的文档中。
Should help. Do what ever you need with the name in the each loop, array, append to div, etc...
edit: edited for completeness, appending the names into the printing div comma separated. Should put this into a document ready, as well.
这是示例 - http://jsfiddle.net/gorsky/AhCAW/
Here is sample - http://jsfiddle.net/gorsky/AhCAW/