Click here to Skip to main content
16,012,173 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
XML
<table>
        <tr>
            <td>
                <table>
                    <tr>
                        <td>
                            <table>
                                <tr>
                                    <td>
                                        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="3"
                                            GridLines="None" BackColor="White" BorderColor="White" BorderStyle="Ridge" BorderWidth="2px"
                                            CellSpacing="1" >
                                            <Columns>
                                                <asp:TemplateField>
                                                    <ItemTemplate>
                                                        <input type ="checkbox" value="" onclick='addthis(this,<%#Eval("EmpSalary") %>)' />

                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField HeaderText="Emp Salary">
                                                    <ItemTemplate>
                                                       <%# Eval("EmpSalary") %>
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                            </Columns>
                                            <FooterStyle BackColor="#C6C3C6" ForeColor="Black" />
                                            <RowStyle BackColor="#DEDFDE" ForeColor="Black" />
                                            <SelectedRowStyle BackColor="#9471DE" Font-Bold="True" ForeColor="White" />
                                            <PagerStyle BackColor="#C6C3C6" ForeColor="Black" HorizontalAlign="Right" />
                                            <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#E7E7FF" />
                                        </asp:GridView>
                                        <input type="text" id="resdiv" value="0" />
                                        <asp:Button ID="bbbtbn" runat="server" Width="50px" onclick="bbbtbn_Click" />


                                    </td>
                                </tr>
                            </table>

                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
    <script type="text/javascript">

        function addthis(tid, val1) {
            if (tid.checked) {
                document.getElementById("resdiv").innerText = parseInt(document.getElementById("resdiv").value) + parseInt(val1);


            }
            else {
                document.getElementById("resdiv").innerText = parseInt(document.getElementById("resdiv").value) - parseInt(val1);
            }

        }


    </script>




this is working in internet explorer.its not working in chrome and firefox.
any solution
Posted

resdiv is a text box, you should use "value" property to set some value in it. use the following:

C#
function addthis(tid, val1) {
           if (tid.checked) {
               document.getElementById("resdiv").value = parseInt(document.getElementById("resdiv").value) + parseInt(val1);


           }
           else {
               document.getElementById("resdiv").value = parseInt(document.getElementById("resdiv").value) - parseInt(val1);
           }

       }
 
Share this answer
 
Hi,


just check that resdiv is textbox so you've to set that values using "value"


you said you changed that div to textbox.then you've to change properties also.

All the Best
 
Share this answer
 
Comments
yerrojumeher 15-Oct-11 9:46am    
i changed it to value aslo but iyts not working in chrome and fire fox

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


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900