473,395 Members | 1,649 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,395 software developers and data experts.

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

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

my tables id is ctl00_ContentPlaceHolder1_Quote1_RadGdProductList_ 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.cells[7].firstChild.value);

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 2138
dmjpro
2,476 2GB
i want to total of all 7th columns(in all rows) of my table

my tables id is ctl00_ContentPlaceHolder1_Quote1_RadGdProductList_ 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.cells[7].firstChild.value);

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_ContentPlaceH older1_Quote1_RadGdProductList_ctl01');

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

var rowTotal=Number(table.rows[i].cells[7].firstChild.value);
subTotal=eval(subTotal)+eval(rowTotal);

}

document.getElementById('ctl00_ContentPlaceHolder1 _Quote1_TxtBxSubTotal').value=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
i have done
alert("..."+table.rows[i].cells[7].firstChild.value);

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 2GB
i have done
alert("..."+table.rows[i].cells[7].firstChild.value);

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
[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="GridHeader_Default">Qty</th><th class="GridHeader_Default">Unit Price</th><th class="GridHeader_Default">Total</th><th class="GridHeader_Default">Cost</th><th >Stock Position</th><th >Source</th>
</tr>
</thead><tbody>
<tr >
<td>)A1</td><td>Techno Flex</td><td>
<input name="ctl00TxtBxProductName" value="100x6x16" id="ctl00TxtBxProductName" class="RadTextBox3" type="text">
</td><td>
<input name="ctl00TxtBxRemarks" id="ctl00TxtBxRemarks" class="RadTextBox3" type="text">
</td><td>
<select name="ctl00DdlUnit" id="ctl00DdlUnit">
<option selected="selected" value="0"> </option>
<option value="1">Litter</option>

</select>
</td><td>
<input name="ctl00TxtBxQuantity" value="1" id='ctl00TxtBxQuantity' type="text">
</td><td>
<input name="ctl00TxtBxPrice" value="0.00" id="ctl00TxtBxPrice" type="text">
</td><td>
<input name="ctl00TxtBxRowTotal" value="0.00" id="ctl00TxtBxRowTotal" type="text" >&nbsp;
</td><td>
<input name="ctl00TxtBxCost" value="0" id="ctl00TxtBxCost" type="text">&nbsp;
</td><td>
<input name="ctl00TxtBxSource" id="ctl00TxtBxSource" 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 2GB
Did you use my code?

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

Debasis Jana.
alert("..."+table.rows[i].childNodes[7].firstChild.value);
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 2GB
alert("..."+table.rows[i].childNodes[7].firstChild.value);
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 Expert Mod 4TB
heya kuttan,

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

[CODE=javascript] 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
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...
2
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...
0
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
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...
9
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...
1
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 ...
4
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...
2
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...
0
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,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...

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.