[英]I already have 3 checkboxes and 1 textbox in asp.net webform when i check 1and 2 checkbox then result in textbox will be 1,2
I already have 3 checkboxes and 1 textbox in asp.net webform when i check 1and 2 checkbox then result in textbox will be 1,2 我在asp.net webform中已经有3个复选框和1个文本框,当我选中1和2复选框时,结果文本框将为1,2
I have the following code : 我有以下代码:
<script type="text/javascript">
function Test(control, value) {
var str = '';
if (control.checked) {
str = value + '\n' + $('#<%=txtTest.ClientID %>').val();
}
else {
str = $('#<%=txtTest.ClientID %>').val().replace(value + '\n', '');
}
$('#<%=txtTest.ClientID %>').val(str);
}
</script>
to do this...... 去做这个......
But the problem in this code ...was when i check 3 and 2 checkbox then result in the textbox is 3,2, 但是这段代码中的问题...是当我选中3和2复选框,然后导致文本框为3,2时,
But i want it appear as 2,3 only ... 但我希望它仅显示为2,3 ...
Can anybody reedit this code ....... ?????? 任何人都可以重新编辑此代码....... ??????
I would be thank ful to u .............. 我会非常感谢你。
如果您只是反转输出怎么办?
$('#<%=txtTest.ClientID %>').val().split(",").reverse().join(",");
This function is triggered when user clicks check box. 用户单击复选框时会触发此功能。 So if you click 2 & 3 by this order, them there is everything right?
因此,如果您按此顺序单击2和3,它们是否正确?
So user "each" sentence: 因此用户“每个”句子:
<script type="text/javascript">
function Test(control, value) {
var str = '';
$('#<%=txtTest.ClientID %> :checked').each(function() {
str = str + ', ' $(this).val();
});
$('#<%=txtTest.ClientID %>').val(str);
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.