Call the javascript function at page_load()
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
rbtnList.Attributes.Add("onclick", "javascript:checkOthersOption('" + rbtnList.ClientID + "');");
}
}
And Add javascript to the aspx page
function checkOthersOption(id)
{
var radioList = document.getElementById(id);
var radio = radioList.getElementsByTagName('input');
alert(radio.length);
for (var i = 0; i < radio.length; i++)
{
if(radio[i].type =="radio")
{
if (radio[i].checked)
alert(radio[i].value);
}
}
}
No comments:
Post a Comment