RadioButtonList
<asp:RadioButtonList ID="RadioButtonList1" runat="server"
RepeatDirection="Horizontal" RepeatLayout="Flow">
msdn相關資料:
http://msdn.microsoft.com/zh-tw/library/System.Web.UI.WebControls.RadioButtonList_properties%28v=vs.110%29.aspx
RepeatDirection : 取得或設定群組中選項按鈕的顯示方向。 // 調整橫向直向
http://msdn.microsoft.com/zh-tw/library/system.web.ui.webcontrols.radiobuttonlist.repeatdirection%28v=vs.110%29.aspx
RepeatLayout : 取得或設定值,這個值指定要使用 table 項目、ul 項目、ol 項目還是 span 項目來呈現清單。
http://msdn.microsoft.com/zh-tw/library/system.web.ui.webcontrols.radiobuttonlist.repeatlayout%28v=vs.110%29.aspx
// CheckBoxList選取 加到 Label.Text
protected void CheckBoxList9_TextChanged(object sender, EventArgs e)
{
String strckbl = ((CheckBoxList)sender).ID.ToString();
ClearInPanelOfCheckBoxList(strckbl);
String strselected= null;
foreach (ListItem listmp in ((CheckBoxList)sender).Items)
{
if (listmp.Selected)
{
strselected += listmp.Text + ",";
}
}
lblcondition.Text = strselected;
}
// CheckBoxList選取後清空其他CheckBoxList
protected void ClearInPanelOfCheckBoxList(string strckbl)
{
Panel mpContentPlaceHolder = (Panel)Panel1;
foreach (object ctrl in mpContentPlaceHolder.Controls)
{
if (ctrl is System.Web.UI.WebControls.CheckBoxList )
{
CheckBoxList textctrl = (CheckBoxList)ctrl;
string strtmp = ((CheckBoxList)textctrl).ID.ToString();
if (strtmp != strckbl)
{
foreach (ListItem listmp in textctrl.Items)
{
listmp.Selected = false;
}
}
}
}
}
////RadioButtonList 用JavaScript取得選取的值,20170413記,測試可用
var list = document.getElementById("radios"); //Client ID of the radiolist
var inputs = list.getElementsByTagName("input");
var selected;
for (var i = 0; i < inputs.length; i++) {
if (inputs[i].checked) {
selected = inputs[i];
break;
}
}
if (selected) {
alert(selected.value);
}
沒有留言:
張貼留言