I need to retrive the id
of a <td>
having only the text content of the <td>
.
For example:
.....
<tr>
<td id='hey'>Hello world!</td>
</tr>
....
If I know the text "Hello world", is it possible to retrive the id
of the <td>
?
/*****/ Thanks to all guys! I will try the solutions offered as soon as possible!! Just to explain i was working with OBIEE 11g and i was trying to write a script to add format condition to grand total that is not supported. Till now i came up with this solution:
<script type="text/javascript">
var threshold = 10; // set the threshold
/*** Definizione colonne da formattare ***/
/*** Partire da 0 ***/
var colonneFormattate = new Array(2);
colonneFormattate[0] = 0;
colonneFormattate[1] = 2;
/************************************************/
var tds = document.getElementsByClassName('PTDT');
for(var td =0; td < colonneFormattate.length;td++){
var amount = (tds[colonneFormattate[td]].innerHTML.replace("€","")).replace(/ /g,'');
//alert(colonneFormattate[td]);
var lungh = amount.indexOf(",");
var novirgole = amount.substring(0,lungh);
var novirgole = novirgole.replace(/\./g,"");
var num = parseInt(novirgole);
if(num > threshold){
tds[colonneFormattate[td]].style.color = "green";
}else{
tds[colonneFormattate[td]].style.color = "red";
}
}
</script>
So in this case the grand total will be coloured if the number is higher then threshold. I ask your help to try to define the column to search in an array to make it more simple for the user. I mean if the user want to format the column named Turnover, it will add in the script the column that he needs.
I will try your suggestion! And i will let you know!
Cheers!