473,769 Members | 2,599 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calculating total of 7th column of my table-->NaN

33 New Member
i want to total of all 7th columns(in all rows) of my table

my tables id is ctl00_ContentPl aceHolder1_Quot e1_RadGdProduct List_ctl01

The first row of the table is headings

the following code works fine in IE7
But I am getting 'NaN' when i use Mozilla

i found that
[i]var rowTotal=Number (table.rows.cel ls[7].firstChild.val ue);

is causing problem
what should i use to do this that do work in Mozilla and fire fox atlest

I don't know much javascript

my code is bellow
............... ............... ............... .......
Expand|Select|Wrap|Line Numbers
  1. function doSubTotal(c){
  2. var subTotal=0;
  3. table=document.getElementById('ctl00_ContentPlaceHolder1_Quote1_RadGdProductList_ctl01');
  4.  
  5. for(var i=1;i<table.rows.length;i++){
  6.  
  7. var rowTotal=Number(table.rows[i].cells[7].firstChild.value);
  8. subTotal=eval(subTotal)+eval(rowTotal);
  9.  
  10. }
  11.  
  12. document.getElementById('ctl00_ContentPlaceHolder1_Quote1_TxtBxSubTotal').value=subTotal;
  13.  
  14. }
............... ............... ............... ............... ............... ...
Oct 12 '07 #1
8 2159
dmjpro
2,476 Top Contributor
i want to total of all 7th columns(in all rows) of my table

my tables id is ctl00_ContentPl aceHolder1_Quot e1_RadGdProduct List_ctl01

The first row of the table is headings

the following code works fine in IE7
But I am getting 'NaN' when i use Mozilla

i found that
[i]var rowTotal=Number (table.rows.cel ls[7].firstChild.val ue);

is causing problem
what should i use to do this that do work in Mozilla and fire fox atlest

I don't know much javascript

my code is bellow
............... ............... ............... .......
function doSubTotal(c){
var subTotal=0;
table=document. getElementById( 'ctl00_ContentP laceHolder1_Quo te1_RadGdProduc tList_ctl01');

for(var i=1;i<table.row s.length;i++){

var rowTotal=Number (table.rows[i].cells[7].firstChild.val ue);
subTotal=eval(s ubTotal)+eval(r owTotal);

}

document.getEle mentById('ctl00 _ContentPlaceHo lder1_Quote1_Tx tBxSubTotal').v alue=subTotal;

}
............... ............... ............... ............... ............... ...
Expand|Select|Wrap|Line Numbers
  1. var rowTotal=Number(table.rows[i].cells[7].firstChild.value);
  2.  
What is "Number" here?
And need not to use "eval" if you convert it into number already.
You can also try this .........

Expand|Select|Wrap|Line Numbers
  1. for(var i=1;i<table.rows.length;i++){
  2. var rowTotal=parseInt(table.rows[i].cells[7].firstChild.value);
  3. subTotal=subTotal+rowTotal;
  4. }
  5.  
Debasis Jana
Oct 12 '07 #2
KUTTAN
33 New Member
i have done
alert("..."+tab le.rows[i].cells[7].firstChild.val ue);

it is the correct number for IE
but
this is undefined for Mozilla

I have also tried parseFloat ,parseInt
nothing good happned
;(
Oct 12 '07 #3
dmjpro
2,476 Top Contributor
i have done
alert("..."+tab le.rows[i].cells[7].firstChild.val ue);

it is the correct number for IE
but
this is undefined for Mozilla

I have also tried parseFloat ,parseInt
nothing good happned
;(
So you are using Mozilla.

Use ..............
Expand|Select|Wrap|Line Numbers
  1. alert("..."+table.rows[i].childNodes[7].firstChild.value);
  2.  
Debasis Jana
Oct 12 '07 #4
KUTTAN
33 New Member
[HTML]<table style="width: 100%; border-collapse: collapse; empty-cells: show;" border="0" cellspacing="0" >
<colgroup>
<col>
<col>
<col>
<col>
<col>
<col>
<col>
<col>
<col>
<col>
<col>
</colgroup>
<thead>
<tr>
<th > Code</th><th >Brand</th><th>Product Name</th><th >Remarks</th><th >Unit</th><th class="GridHead er_Default">Qty </th><th class="GridHead er_Default">Uni t Price</th><th class="GridHead er_Default">Tot al</th><th class="GridHead er_Default">Cos t</th><th >Stock Position</th><th >Source</th>
</tr>
</thead><tbody>
<tr >
<td>)A1</td><td>Techno Flex</td><td>
<input name="ctl00TxtB xProductName" value="100x6x16 " id="ctl00TxtBxP roductName" class="RadTextB ox3" type="text">
</td><td>
<input name="ctl00TxtB xRemarks" id="ctl00TxtBxR emarks" class="RadTextB ox3" type="text">
</td><td>
<select name="ctl00DdlU nit" id="ctl00DdlUni t">
<option selected="selec ted" value="0"> </option>
<option value="1">Litte r</option>

</select>
</td><td>
<input name="ctl00TxtB xQuantity" value="1" id='ctl00TxtBxQ uantity' type="text">
</td><td>
<input name="ctl00TxtB xPrice" value="0.00" id="ctl00TxtBxP rice" type="text">
</td><td>
<input name="ctl00TxtB xRowTotal" value="0.00" id="ctl00TxtBxR owTotal" type="text" >&nbsp;
</td><td>
<input name="ctl00TxtB xCost" value="0" id="ctl00TxtBxC ost" type="text">&nb sp;
</td><td>
<input name="ctl00TxtB xSource" id="ctl00TxtBxS ource" type="text">
</td>
</tr>
</tbody>

</table>[/HTML]

this is my table structure
my table structure is the problem ,there is a tbody
Oct 12 '07 #5
dmjpro
2,476 Top Contributor
Did you use my code?

Debasis Jana.
Oct 12 '07 #6
KUTTAN
33 New Member
Did you use my code?

Debasis Jana.
alert("..."+tab le.rows[i].childNodes[7].firstChild.val ue);
this is undefined in Mozilla
but ok in IE
my table has tbody thead etc is it a problem?
Oct 12 '07 #7
dmjpro
2,476 Top Contributor
alert("..."+tab le.rows[i].childNodes[7].firstChild.val ue);
this is undefined in Mozilla
but ok in IE
my table has tbody thead etc is it a problem?
I think so .. though I am not sure about that.
So have the reference of "TBODY" then try with ....

Expand|Select|Wrap|Line Numbers
  1. tbody.chidlNodes[i].childNodes[7].firstChild.value
  2.  
Debasis Jana
Oct 12 '07 #8
gits
5,390 Recognized Expert Moderator Expert
heya kuttan,

please use code tags when posting source-code ... for example:

[CODE=javascrip t] your code here [/code]

kind regards
Oct 12 '07 #9

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

Similar topics

4
12682
by: John | last post by:
hey all..... alright, I am frusterated to the point of throwing my machine out the window (this board went down, trying to find stuff on google, this has been a nightmare) so I hope you guys can help me with a solution. This is what I am trying to do: Pretty much, there are two dates in my database, a start date, and an end
2
2644
by: MT | last post by:
Hi, I have an invoicing system using postgresql. Each time a customer makes a purchase, a new record is inserted into the "cart" table. The "cart" table, among other things, contains a customer_id field and a total for the amount purchased on the particular invoice. Now what I'd like to do is to calculate the total invoices for each customer in a given time interval, then list those customers in descending order from most paying to least...
0
1585
by: Terry Olsen | last post by:
Is there a way to get the total column count in a DataGrid? I can get the total _visible_ columns, but I need to know how many _total_ columns are in my grid. Thanks!
9
2457
by: mankolele | last post by:
Hi all I need an idea on where to start when calculating a total amount betwee n two dates from a database like I want amount of money paid out from 30/03/2004 and 30/07/2004 ,but in the database these dates are not captured as they come they are mixed as some may come two years later to be captured. I have to go throught the database taking in those apropriate dates I need and add them up. I belive I need to use a while loop and add the...
9
11294
parshupooja
by: parshupooja | last post by:
Hi I am using asp.net C# and javascript. I have a gridview with 5 columns and 14 row column1--column2--column3--column4--column5 Column1 to column4 is textboxes wheresa column5 is label I am trying to calculate column 5 which is (column2-column1)+(column4-column3) Here is javascript i am using. When i use this it just calculates for first row of gridview. <script language =javascript type="text/javascript">
1
1272
by: erics44 | last post by:
Hi I have a Matrix in a report and i want the total column to sum a different field that is in the column group, is there any way of doing this? here is an example of my matrix | =Fields!x.value | Total | Fields!Valiant.Value | =Fields!Text.Value | =SUM(Fields!y.value) | the verical linbes are suppost to show the end of each cell.
4
4033
by: sumit kale | last post by:
Hi, Can somebody help me resolve my problem ? I am getting error when calculating total using unbound textfiled in subform. I have a main form called purchase_register_master and a subform called purchase_register_details, In sub form i have a unbound textfield called txt_Total_Amount where in i am calculating total amount for different items purchased by giving following code in control source. ContolSource: =Sum() In my main form i...
2
2638
by: NareshN | last post by:
Hi All, I am calculating totaltime of the employee for each day.I want weekly totaltime working hours.I am using for loop to calculate totaltime for 1 week.But i am storing Total time in String.How to add totaltime for week. If i use DateTime i am getting date also but i want only time. TotalTime - 9:00 for 1 day. I should use Static variable to keep the Previous TotalTime in varible so that i can add previous and current day...
0
1868
by: tnynyn | last post by:
I have created a form with two datetimepicker showing only hours (start and end times). I have timespan calculating the total hours, but when it goes to the next day, it adds 24 hours. For example, from 9PM to 11PM it calculates 2 hours total, but when it goes from 9Pm to 12AM, it jumps to 21 hours. I want it show 3 hours instead, but not sure how to do this. Heres what I have so far: timeEnd.Format = DateTimePickerFormat.Custom;...
0
9589
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10212
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10047
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9863
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7410
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6674
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3962
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3563
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.