473,399 Members | 2,278 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

How to get values of textbox in listview and perform calculations in javascript?

image of my listview:



I want to total every row from my listview

tallies total infected people and percentage
__________________________________________________ __________________
CityID | City | Population | Male | Female | Total | Percentage |

Population, male, and female columns are user inputs
total column is male+female textbox value per row
percentage= (total/population)*100 also per row
to calculate total and percentage on every textchange

here is my html code:


Expand|Select|Wrap|Line Numbers
  1.  
  2. <asp:ListView ID="ListView1" runat="server">
  3.    <LayoutTemplate>
  4.       <table style="border: solid 2px #336699;" cellspacing="0" cellpadding="3" rules="all">
  5.          <tr style="background-color: #336699; color: White;">
  6.  
  7.             <th>City</th>
  8.             <th>Population</th>
  9.             <th>Male</th>
  10.             <th>Female</th>
  11.             <th>Total</th>
  12.             <th>%</th>
  13.          </tr>
  14.          <tbody>
  15.             <asp:PlaceHolder ID="itemPlaceHolder" runat="server" />
  16.          </tbody>
  17.       </table>
  18.    </LayoutTemplate>
  19.    <ItemTemplate>
  20.       <tr>
  21.         <td> <asp:Label ID="lblCtyID" runat="server" Text='<%# Bind("CityID") %>' /> </td>
  22.         <td> <asp:Label ID="lblCty" runat="server" Text='<%# Bind("CityName") %>'/> </td>
  23.          <td><asp:TextBox ID="txtPopu" runat="server"/></td>
  24.          <td>
  25.          <asp:TextBox ID="txtMale" runat="server" Width="69px" ValidationGroup="check"/>
  26.          <asp:RegularExpressionValidator ID="RegularExpressionValidator1" Display="Dynamic" runat="server" ForeColor="Maroon" SetFocusOnError="True" ControlToValidate="txtMale" ErrorMessage="X" ValidationExpression="[0-9]*" ValidationGroup="check"></asp:RegularExpressionValidator>
  27.          </td>
  28.          <td><asp:TextBox ID="txtFemale" runat="server" Width="69px" onpaste = "return false;" onkeyup ="keyUP(event.keyCode)" onkeydown = "return isNumeric(event.keyCode);"/></td>
  29.          <td><asp:TextBox ID="txtTotal" runat="server" enabled="false" Width="85px"/></td>
  30.          <td><asp:TextBox ID="txtPercent" runat="server" enabled="false" Width="85px"/></td>
  31.  
  32.       </tr>
  33.    </ItemTemplate>
  34. </asp:ListView>
  35.         <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Save Info"
  36.             Width="136px" />
  37. <br />
  38.         <asp:SqlDataSource ID="SqlDataSource1" runat="server"
  39.             ConnectionString="<%$ ConnectionStrings:GeraldConnString2 %>"
  40.             SelectCommand="SELECT [CityID], [CityName] FROM [Cities]"></asp:SqlDataSource>
  41.  
  42.  
  43.  
Nov 29 '10 #1
2 5275
Frinavale
9,735 Expert Mod 8TB
Well, in JavaScript you need to get a reference to the table that contains your TextBoxes.

Then you need to loop through each row in the table and retrieve all of the TextBoxes within the row (using the getElementsByTagName method).

Then you need to loop through your TextBoxes and retrieve the data that the user provided...convert the values entered into numbers and perform your calculations.

The question is, when do you do this?
Dec 6 '10 #2
Use JQuery, you feel the power of unobtrusive DOM parsing
Dec 8 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: peter | last post by:
I have created a MS Access query where one of the fields displays the week number. The field is a date value that uses the ww format to display the week number. However, when I try to create a...
2
by: RobRich | last post by:
I'm trying to figure out the best way to accomplish a task. I need to calculate the numerical values from about 300+ textboxes. Basiclly I have an application that users input checks and credit...
1
by: snipersix | last post by:
How do you display values in a textarea using javascript. ex. i have 2 radio buttons o Adult =$9.99 o Child =$6.99 i need it to be, so that if i select adult in the...
1
by: satees | last post by:
Hi, I have a textbox control in Footer Template within datagrid. I need to validate the textbox using client side javascript. When trying it, i got an error that the control not exist. I think the...
7
by: gsaray101 | last post by:
there is a csv file like this: date, val1, val2, val3, val4 etc 1/2/2007, 1, 4, 5, 6 1/3/2007, 2, 5, 7, 10 1/5/2007, 5, 6, 8, 11 what I need...
2
by: franklin moses | last post by:
how do i insert textbox values to ms access using javascript
6
by: john | last post by:
I have the following textbox setup with Text & ToolTip Bindings as follows; I'm using Visual Studio 2008 VB: <asp:TextBox ID="txtDay1" runat="server" Text='<%# Eval("Day1") %>'...
1
by: varunkumarid | last post by:
Hi to All, I want to Compare the Two Textbox ClientId not a Value of them, whether clientid is equal i perform something oterwise not. for (var i = 2; i <=...
3
by: JJ692 | last post by:
I created a form in Access 2007 where some of the fields are "auto filled" from lookup tables. For example, I have a lookup table named "classes taken" which has the columns "class name", "units",...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.