cancel
Showing results for 
Search instead for 
Did you mean: 

Access Table values with Javascript

sap_cohort
Active Contributor
0 Kudos
79

Hi,

Can someone show how to access the 2 table <TD> values via javascript and output the values?

The catch is that I'm trying to do this with Javascript using the <DIV> ID "daterange" identifier instead of the Table Name ID. Is this possible?


<div id="daterange"  style="VISIBILITY: hidden" >
     <span id="sapbi_snippet_DATE_RANGE_OUTPUT">
          <table id="DATE_RANGE_OUTPUT_interactive_pivot" border="1px" >
               <tr><td>03/07/2008</td></tr>
               <tr><td>03/14/2008</td></tr>
          </table>
     </span>
</div>

View Entire Topic
former_member185132
Active Contributor
0 Kudos

Hi Kenneth,

getElementByTagName returns an array, so we'll have to loop through and pick up the array elements like this:


var DIV;
var TD;

DIV = document.getElementById("daterange");
TD = DIV.getElementsByTagName("TD");
var TDCount=TD.length;

for ( var i = 0; i < TDcount; i++)
{
var thtml = TD<i>#innerHTML#
document.write(thtml);
}

Edited by: Suhas Karnik on Apr 22, 2008 4:07 PM

sap_cohort
Active Contributor
0 Kudos

Thanks Andrew and Suhas! I now have what I need. I really appreciate you sticking through to the end!

Points awarded.