RadioButtonList javascript firing twice
Posted
by Muralidhar
on Stack Overflow
See other posts from Stack Overflow
or by Muralidhar
Published on 2010-05-28T19:38:10Z
Indexed on
2010/05/28
19:42 UTC
Read the original article
Hit count: 232
radiobuttonlist
I am working with .NET 1.1. The RadioButtonList's AutoPostBack is set to TRUE. I added a client script to display an alert with the selected value. But, the alert is displaying twice - before and after the post back.
Here is the code..
//javascript function getRadioButtonListSelection(radioButtonListId) { var elementRef = document.getElementById(radioButtonListId); var radioButtonListArray = elementRef.getElementsByTagName('input'); var checkedValues = '';
for (var i=0; i<radioButtonListArray.length; i++)
{
var radioButtonListRef = radioButtonListArray[i];
if ( radioButtonListRef.checked == true )
{
checkedValues = radioButtonListRef.value;
break;
}
}
alert(checkedValues);
}
//code behind in Page_load() rbl.Attributes.Add("onclick", "javascript:getRadioButtonListSelection('" + rbl.ClientID + "');");
where could I went wrong?
© Stack Overflow or respective owner