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
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, 开发者_如何学C
But i want it appear as 2,3 only ...
Can anybody reedit this code ....... ??????
I would be thank ful to u ..............
This function is triggered when user clicks check box. So if you click 2 & 3 by this order, them there is everything right?
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>
What if you just reverse the output?
$('#<%=txtTest.ClientID %>').val().split(",").reverse().join(",");
精彩评论