views:

17

answers:

0

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?

related questions