//把checkboxlist值付给 textbox
function confirm(partId)
{
//alert(partId)
//在JS端调用CheckBoxList
var dvobj = $('dv'+partId);
var chkInput =$('ctl00_ContentPlaceHolder1_chbList'+partId).getElementsByTagName("INPUT");
//var arrListValue = $('ctl00_ContentPlaceHolder1_chbList'+partId).ListValue.split(',');
var arrListText = $('ctl00_ContentPlaceHolder1_chbList'+partId).ListText.split(',');
var count = arrListText.length;
var strCheckChecked = "";
var arrCheckChecked;
//var chkValue = "";
var chkText = "";
//每次点击CheckBoxList的一个Item,都循环把所有Item的选中状态按0、1标志,存入一个变量,最后再根据这个标志来决定checkboxlist中要取的值
for (var i=0; i< chkInput.length; i++)
{
if(chkInput[i].checked)
strCheckChecked = strCheckChecked + "1" + ",";
else
strCheckChecked = strCheckChecked + "0" + ",";
}
arrCheckChecked = RTrim(strCheckChecked).split(',');
for(var j = 0; j < arrCheckChecked.length; j++)
{
if(arrCheckChecked[j] == "1")
//chkValue += arrListValue[j] +",";
chkText += arrListText[j] +",";
}
$('ctl00_ContentPlaceHolder1_txt'+partId).value = RTrim(chkText,',');
$('ctl00_ContentPlaceHolder1_txt'+partId).title = RTrim(chkText,',');
dvobj.hide();
}
-------------------------------.cs-----------------------------------
string checkListValue = "";
string checkListText = "";
foreach (ListItem li in cbl.Items)
{
checkListValue += li.Value + ",";
checkListText += li.Text + ",";
}
checkListText = checkListText.TrimEnd(',');
checkListValue = checkListValue.TrimEnd(',');
//由于checkboxlist在前台html页面表现中没有value属性,导致js无法获取选种的value值
//这里用程序来添加value和text属性
cbl.Attributes["ListValue"] = checkListValue;
cbl.Attributes["ListText"] = checkListText;
function confirm(partId)
{
//alert(partId)
//在JS端调用CheckBoxList
var dvobj = $('dv'+partId);
var chkInput =$('ctl00_ContentPlaceHolder1_chbList'+partId).getElementsByTagName("INPUT");
//var arrListValue = $('ctl00_ContentPlaceHolder1_chbList'+partId).ListValue.split(',');
var arrListText = $('ctl00_ContentPlaceHolder1_chbList'+partId).ListText.split(',');
var count = arrListText.length;
var strCheckChecked = "";
var arrCheckChecked;
//var chkValue = "";
var chkText = "";
//每次点击CheckBoxList的一个Item,都循环把所有Item的选中状态按0、1标志,存入一个变量,最后再根据这个标志来决定checkboxlist中要取的值
for (var i=0; i< chkInput.length; i++)
{
if(chkInput[i].checked)
strCheckChecked = strCheckChecked + "1" + ",";
else
strCheckChecked = strCheckChecked + "0" + ",";
}
arrCheckChecked = RTrim(strCheckChecked).split(',');
for(var j = 0; j < arrCheckChecked.length; j++)
{
if(arrCheckChecked[j] == "1")
//chkValue += arrListValue[j] +",";
chkText += arrListText[j] +",";
}
$('ctl00_ContentPlaceHolder1_txt'+partId).value = RTrim(chkText,',');
$('ctl00_ContentPlaceHolder1_txt'+partId).title = RTrim(chkText,',');
dvobj.hide();
}
-------------------------------.cs-----------------------------------
string checkListValue = "";
string checkListText = "";
foreach (ListItem li in cbl.Items)
{
checkListValue += li.Value + ",";
checkListText += li.Text + ",";
}
checkListText = checkListText.TrimEnd(',');
checkListValue = checkListValue.TrimEnd(',');
//由于checkboxlist在前台html页面表现中没有value属性,导致js无法获取选种的value值
//这里用程序来添加value和text属性
cbl.Attributes["ListValue"] = checkListValue;
cbl.Attributes["ListText"] = checkListText;