Click here to Skip to main content
12,358,775 members (62,541 online)
Rate this:
 
Please Sign up or sign in to vote.
I have a radiobuttonlist in my web application I have an event onclick for this it works fine in IE but not in some other browsers. The sample code is as follows
<asp:RadioButtonList ID="rbgThreadStatus" runat="server" RepeatDirection="Horizontal"
                                                OnSelectedIndexChanged="rbgThreadStatus_SelectedIndexChanged" onclick="return rdblst_onClick();" AutoPostBack="True">
  <asp:ListItem Selected="True" Value="0">Alpha</asp:ListItem>
  <asp:ListItem Value="1">Bravo</asp:ListItem>
  <asp:ListItem Value="2">Charlie</asp:ListItem>
  <asp:ListItem Value="3">Delta Tickets</asp:ListItem>
  <asp:ListItem Value="4">Echo</asp:ListItem>
  </asp:RadioButtonList> <input type="hidden" value="0" id="hdnValue" runat="server" />

Following is the Javascript

function rdblst_onClick()
{
    var hdnValue = document.getElementById('ctl00_ctl00_MainMaster_ContentPlaceHolder2_hdnValue');
    var length = document.getElementById('ctl00_ctl00_MainMaster_ContentPlaceHolder2_rbgThreadStatus').cells.length;
    for (var i = 0; i < length; i++)
    {
        if (document.getElementById('ctl00_ctl00_MainMaster_ContentPlaceHolder2_rbgThreadStatus_' + i.toString()).checked)
        {
            if (hdnValue.value != document.getElementById('ctl00_ctl00_MainMaster_ContentPlaceHolder2_rbgThreadStatus_' + i.toString()).value)
            {
                hdnValue.value = document.getElementById('ctl00_ctl00_MainMaster_ContentPlaceHolder2_rbgThreadStatus_' + i.toString()).value;
                //Some code here
            }
        }
    }
}
Posted 25-Aug-11 19:23pm
Updated 25-Aug-11 19:32pm
v3

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

There might be any error in javascript.
Its working fine at my end.

Try this code in a new page. Its working.
<asp:RadioButtonList ID="rbgThreadStatus" runat="server" RepeatDirection="Horizontal"
            OnSelectedIndexChanged="rbgThreadStatus_SelectedIndexChanged" onclick="return rdblst_onClick();" />
        <asp:ListItem Selected="True" Value="0">Alpha</asp:ListItem>
        <asp:ListItem Value="1">Bravo</asp:ListItem>
        <asp:ListItem Value="2">Charlie</asp:ListItem>
        <asp:ListItem Value="3">Delta Tickets</asp:ListItem>
        <asp:ListItem Value="4">Echo</asp:ListItem>
        </asp:RadioButtonList>
        <input type="hidden" value="0" id="hdnValue" runat="server" />
        <script type="text/javascript">
            function rdblst_onClick() {
                alert('hello');
            }
        </script>
  Permalink  
Comments
MathewPV 26-Aug-11 2:03am
   
The above code I have posted works fine in IE but not in other browsers

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160621.1 | Last Updated 26 Aug 2011
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100