Hello,
I wish to extract some text from certain elements on the page and
process them. I've done this in the past by keying on the className
but I don't have that option in this case. Below is an example of what
I have to work with. I need to extract the SKU, Product, Qty, Price &
Extended Price.
Here's one try I made:
function getValue(name){
var elements = document.getElementsByTagName("span");
for (var i = 0; i < elements.length; i++){
var l = elements[i];
if (l.className.match("default") && l.data.match("SKU")){
alert(l.data);
}
}
}
As you can see, I'm missing some essential understanding of how to
access the text within the <span> tag. Any help would be much
appreciated.
Thanks.
mp
<tr valign="top">
<!-- -------------------------- Item# / SKU -------------------------- -->
<td width="4"><img src="invoicemain.jsp_files/spacer01.gif" border="0"
height="1" width="4"></td>
<td><span class="default">TP59524</span></td>
<!-- -------------------------- Product ------------------------------ -->
<td width="4"><img src="invoicemain.jsp_files/spacer01.gif" border="0"
height="1" width="4"></td>
<td><span class="default">Product One Description</span></td>
<!-- -------------------------- Status ------------------------------ -->
<td width="4"><img src="invoicemain.jsp_files/spacer01.gif" border="0"
height="1" width="4"></td>
<td><span class="default">In Stock</span></td>
<!-- -------------------------- Quantity ----------------------------- -->
<td width="4"><img src="invoicemain.jsp_files/spacer01.gif" border="0"
height="1" width="4"></td>
<!--<INPUT name="qty" value="" size=3 maxlength=3>-->
<td align="center"><span class="default">6</span></td>
<!-- -------------------------- Price -------------------------------- -->
<td width="4"><img src="invoicemain.jsp_files/spacer01.gif" border="0"
height="1" width="4"></td>
<td align="right"><div class="default">$2.99</div>
</td>
<!-- -------------------------- Extended Price ----------------------- -->
<td width="4"><img src="invoicemain.jsp_files/spacer01.gif" border="0"
height="1" width="4"></td>
<td align="right"><div class="default">$17.94</div>
</td>
<!-- -------------------------- Remove Item -------------------------- -->
<td width="4"><img src="invoicemain.jsp_files/spacer01.gif" border="0"
height="1" width="4"></td>
<td align="center"><a href="https://www.domain.com/checkout/invoice/invoicemain.jsp?remove=6929940&orderID=5943646 " class="xremove">Remove</a></td>
<td><img src="invoicemain.jsp_files/spacer01.gif" border="0"
height="1" width="4"></td>
</tr>
--
Michael Powe mi*****@trollope.org Naugatuck CT USA
"I don't like America because America doesn't like the world."
- Ahmed Sultan Ghanem, 25-year-old Saudi student