Solved

Javascript - headers == undefined in a tabular form...

Posted on 2007-04-02
3
826 Views
Last Modified: 2008-01-09
Hi All,
I have a snippit of my html from View Source:

I am try to access the 3565 which is one of the values in a tabular report. I want to get all the amounts in form.

<td headers="CMT_OPTION_000" class="t2data"><input type="hidden" name="f47" value="Option 1" />Option 1</td><td align="right"  headers="Price NetVision Member_000" class="t2data">3565</td>

I tried using:
   var tds = document.getElementsByTagName('td');
   for (var i=0; i<tds.length; i++) {
       alert(tds(i).headers);
  }
Then I was going to get the innerHTML
BUT the alert shows undefined
0
Comment
Question by:bcarlis
3 Comments
 
LVL 2

Assisted Solution

by:rhawk
rhawk earned 50 total points
ID: 18843143
Try changing the alert line to:
 alert(tds(i).getAttribute(headers));
0
 
LVL 29

Accepted Solution

by:
Badotz earned 200 total points
ID: 18848716
Or more correctly:

alert(tds(i).getAttribute('headers'));
0
 
LVL 2

Author Comment

by:bcarlis
ID: 18869786
Actually the alert(alltds[j].headers); worked fine... it was something else in my syntax..
Thanks for the help..

Incase anyone needs to use headers:

var alltds = theTable.getElementsByTagName('td');
  var Option1row = false;
  for(var j=0;j<alltds.length;j++){ // for alltds
     //alert(alltds[j].headers);
     if (alltds[j].headers=="CMT_OPTION_000"){ //if my headers
       var elemAllC = alltds[j].getElementsByTagName('input');
       // Check the only 'input' element in the 'td'
       if(elemAllC[0].value=='Option 1'){
            Option1row=true;
       }else{
            Option1row=false;
       }
     } //if my headers

     if(!Option1row){ //(!Option1row)
       if (alltds[j].headers=="Price NetVision Member_000"){
          // Get the Row that we are in
          var theRow = html_CascadeUpTill(alltds[j],'TR');  
          // Get all the input elements in that Row.
          var elemAll = theRow.getElementsByTagName('input');

          // Go through all 'input' elements to assign Original Value
          for(var b=0;b<elemAll.length;b++){ //elemAll for
             if(elemAll[b].name=="f48"){ //f48
                  var original = elemAll[b].value;
                  //if original is null then innerHTML is the original
                  if (original==''){ //chkorig
                     original = alltds[j].innerHTML;
                     elemAll[b].value = original;
                  }//chkorig
             } //f48
          }//elemAll for
           
          var newPrice=stripCharsInBag(original,'$');
          newPrice=stripCharsInBag(newPrice ,',');
          newPrice = parseFloat(newPrice)*discountPercentage;
          var strPrice = FormatWithDecimals(newPrice,2);
          alltds[j].innerHTML = '$'+strPrice;
       } // if Price
     } //(!Option1row)
   }  // for LOOP alltds
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The business world is becoming increasingly integrated with tech. It’s not just for a select few anymore — but what about if you have a small business? It may be easier than you think to integrate technology into your small business, and it’s likely…
The advancement in technology has been a great source of betterment and empowerment for the human race, Nevertheless, this is not to say that technology doesn’t have any problems. We are bombarded with constant distractions, whether as an overload o…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question