SID-01165: Comparing text of a Twiki Table
| Status: |
Answered |
TWiki version: |
5.0.0 |
Perl version: |
5.005 |
| Category: |
CategoryJavaScript |
Server OS: |
RedHat Linux |
Last update: |
14 years ago |
Hello, I have a comment template that outputs a table where the rows look like this:
And I want to be able to pull the rows from the table into another table based on the info in the second cell.
I wrote a javascript function, shown below, but I can't get it to compare the cell contents to check for HP. Any guidance you have here?
showHp()
{
var theRows=document.getElementById("table1").getElementsByTagName('tr');
var numRows=theRows.length;
numRows=numRows-1;
for(i=numRows;i>=0;i=i-1)
{
var rowMan=theRows[i].cells[1].firstChild.data;
if (rowMan == "Hp")
{
var rowToAdd=document.getElementById("table1").rows[i];
var newRow=rowToAdd.cloneNode(true);
document.getElementById("outPutTable").appendChild(newRow);
}
}
}
--
JoshuaTatman - 2011-05-04
Discussion and Answer
Hello,
Different approach (TWiki native)
Check
SearchPatternCookbook
Instead of producing a the option list of the example you could produce the table you want.
--
EnriqueCadalso - 2011-05-05
I figured it out, thank you much.
--
JoshuaTatman - 2011-05-06
If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.