Click here to Skip to main content
11,629,481 members (65,393 online)
Rate this: bad
good
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
Edited 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 at 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


Advertise | Privacy | Mobile
Web04 | 2.8.150723.1 | Last Updated 26 Aug 2011
Copyright © CodeProject, 1999-2015
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