[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

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

Posted on 2007-04-02
3
Medium Priority
?
850 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 2

Assisted Solution

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

Accepted Solution

by:
Badotz earned 800 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

An overview of cyber security, cyber crime, and personal protection against hackers. Includes a brief summary of the Equifax breach and why everyone should be aware of it. Other subjects include: how cyber security has failed to advance with technol…
Here in this article, you will get a step by step guidance on how to restore an Exchange database to a recovery database. Get a brief on Recovery Database and how it can be used to restore Exchange database in this section!
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

656 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