With JavaScript you could count the <td>/<tr>-elements (works only in IE!),
if in the HTML-source you set the name of the last <td>/<tr>-element to name
(<td name="name">):
function countTD() {
numberOfTDElements = document.all.name.sourceIndex;
alert("Number of <td>-elements: " + numberOfTDElements);
}
The second one is a bit more tricky.
You must create a JavaScript-function that reads the content of the
<td>-elements, creates depending on these values an URL to your servlet
which you want the <td>-values to be passed to.
For example:
function getTDContent() {
allTDs = countTD(); // used the other script to get the number of <td>'s
used
var url = "http://server/servlet/ServletName";
for (i = 0; i < allTDs; i++)
if (i==0)
url += "?parameter" + i + "=" +
document.all.tags("td")[i].innerText;
else
url += "¶meter" + i + "=" +
document.all.tags("td")[i].innerText;
}
return url;
}
function openServlet() {
window.document.location.href = getTDContent();
}
Note: Both Scripts will only work with Internet Explorer because Netscape
doesn't know the 'all' element,if you want to use them in Netscape you must
replace all those 'all.tags("td")[index]' with 'all.elementName'!
-mw
----- Original Message -----
From: "Ramesh, Kesav" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, January 08, 2001 10:39 AM
Subject: clarification please
> I have an html page. say a table element with 5 <tr> and each <tr> is
having
> 10<td>'s
>
> First of all is it possible to know the number of <tr> or <td> elements in
> html.
>
> Then through my servlet i want to retrieve only the contents of the <td>
> alone. Is it possible?
>
>
>
> Regards
>
> Ramesh Kesavanarayanan
>
> Electronic Data Systems
> Steeple Reach,
> 25, Cathedral Road,
>
> 91-44-811 3801 to 15 ext :2186
> 91-44-233 0380 (res)
> [EMAIL PROTECTED]
> [EMAIL PROTECTED]
>
>
___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html