| View previous topic :: View next topic |
| Author |
Message |
decren
Joined: 07 Apr 2007 Posts: 4 Location: MS
|
Posted: Tue Apr 17, 2007 2:38 pm Post subject: adding column numbers |
|
|
Hello,
I have a table with an add-row setup. The table has several columns but I only need to calculate COLUMN FOUR. The results go to a textbox via a button. My code is.....
| Code: |
function sumup() {
document.getElementById("Table1")
column = document.getElementsByTagName("colFour");
document.myForm.tbTotal.value = column;
} |
.....
| Code: |
<TABLE NAME="Table1" id="Table1">
<COL WIDTH=10*>
<COL WIDTH=139*>
<COL WIDTH=27*>
<COL WIDTH=29*>
<COL WIDTH=27* NAME="colFour" id="colFour">
<COL WIDTH=10*> |
.....
| Code: |
<INPUT TYPE=TEXT NAME="tbTotal">
<INPUT TYPE=BUTTON NAME="pbTest" VALUE="TEST" onclick="sumup();"./> |
.....But when I click pbTest, the result in tbTotal is, with the brackets.....
[object]
.....What am I doing wrong? |
|
| Back to top |
|
 |
|
|
kroyce
Joined: 17 Apr 2007 Posts: 4
|
Posted: Tue Apr 17, 2007 7:33 pm Post subject: your column variable is an element object with properties |
|
|
However, the values you want are probably textNodes within each cell in the column.
It might be helpful to show the entire html for your table. |
|
| Back to top |
|
 |
decren
Joined: 07 Apr 2007 Posts: 4 Location: MS
|
Posted: Tue Apr 17, 2007 9:45 pm Post subject: Re: adding column numbers |
|
|
Instead of Table1 as stated above the actual is Table4 - and the entire page is located at.....
http://www.aaronzjukebox.com/R2CDorder1
You may notice that the column 4 heading is 0 (zero) to prevent conflict while I am trying to figure out this problem, but the actual heading will not be numeric.
Thank you in advance for any assistance that you may offer. |
|
| Back to top |
|
 |
kroyce
Joined: 17 Apr 2007 Posts: 4
|
Posted: Tue Apr 17, 2007 10:27 pm Post subject: Re: adding column numbers |
|
|
After looking at the page, I think you are referring to values that are contained in text boxes in table 3. Each textbox needs an id so you can use the document.getElementById("textboxid").value property. I don't know of any other way to do what you want to do.
In order to make this work you would want to give each textbox an id that is easily accessible by javascript on the fly. id may equal something like sumcolumn_i where i iterates with the number of columns. you could then iterate through the values and add them up.
It looks like you add a row each time you process a record. that is the logical place to add the id to each textbox.
I hope this helps. |
|
| Back to top |
|
 |
decren
Joined: 07 Apr 2007 Posts: 4 Location: MS
|
Posted: Tue Apr 17, 2007 11:05 pm Post subject: Re: adding column numbers |
|
|
| Thank you for your response. You have given me some food for thought (never looked at referencing to the row number.) I'll let you know how it turns out... and again thanks. |
|
| Back to top |
|
 |
decren
Joined: 07 Apr 2007 Posts: 4 Location: MS
|
Posted: Sat May 05, 2007 12:39 pm Post subject: Re: adding column numbers |
|
|
I want to thank everyone at DEVPPL for their input to this problem. With your help and with a table located at:
http://4umi.com/web/javascript/
I was able to work out a solution. If anyone is interested in (what I believe to be unique) addRow/shoppingCart type form, you are welcome to take what you need from my page (as shown on a previous post to this problem)
Understand though that it is a work in progress so you will have to sift through a lot of garbage to get the scripts to your particular need.
And thanx again |
|
| Back to top |
|
 |
kroyce
Joined: 17 Apr 2007 Posts: 4
|
Posted: Mon May 07, 2007 1:49 pm Post subject: Solution |
|
|
Nice, concise solution. Thanks for sharing.  |
|
| Back to top |
|
 |
|