Solved

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

Posted on 2007-04-02
3
806 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Moving applications to the cloud or switching services to cloud-based ones, is a stressful job.  Here's how you can make it easier.
Are you unable to connect or configure Hotmail email account in Microsoft Outlook 2010, 2007? Or Outlook.com emails are not downloading to Outlook? Lets’ see the problem and resolve Outlook Connector error syncing folder hierarchy (0x8004102A).
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

744 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now