Link to home
Start Free TrialLog in
Avatar of BILL Carlisle
BILL CarlisleFlag for United States of America

asked on

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

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
SOLUTION
Avatar of rhawk
rhawk

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of BILL Carlisle

ASKER

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