简体   繁体   English

我在asp.net webform中已经有3个复选框和1个文本框,当我选中1和2复选框时,结果文本框将为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

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.

相关问题 onkeypress无法与asp.net Webform中的文本框一起使用 - onkeypress is not working with textbox in asp.net webform 当我在文本框中键入任何内容时,它应该在asp.net中启动? - When I type anything in Textbox then it should fire in asp.net? 用户使用JQuery切换到Asp.net文本框值时,如何用它替换以前的asp.net文本框值? - How can I fill an asp.net textbox with a previous asp.net textbox value when the user tabs to it using JQuery? 我有一个文本框,我希望用户单击按钮时可以切换到网格。 在asp.net中可以吗? - I have a textbox which I would like to allow my users to switch to a grid when they click a button. Is this possible in asp.net? 当onkeyup事件定义“ setTimeout”(IE9)时,ASP.NET / Webform文本框不会触发自动回发 - ASP.NET/Webform Textbox does not fire the autopostback when onkeyup event defines “setTimeout” (IE9) 检查ASP.NET中文本框的验证状态 - Check validate status of textbox in ASP.NET 选中复选框后如何启用文本框 - How can I enable the textbox when the checkbox is check 如何在asp.net中自动调整文本框的高度? - How can I autosize textbox height in asp.net? 如何在 asp.net 网站中实现 SOTag 文本框? - How can I implement SOTag textbox in asp.net website? "如何在 ASP.NET 文本框中强制输入为大写?" - How can I force input to uppercase in an ASP.NET textbox?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM