Hi,
here is a javascript I use to conditionlly format rows of a tr:table.
You can modify it so that's called on all the rows of your table and invoke
it once the table has been loaded:
function conditionallyFormatRowBackground(tableId,
columnId,
columnValue,
backgroundColor){
var rows = document.getElementsByTagName('td');
for (var i=0; i < rows.length; i++)
{
var row = rows[i];
var rowValue = row.innerHTML.substring(row.innerHTML.indexOf('>')+1);
if((row.getAttribute('headers') == tableId + ":" + columnId)
&& rowValue == columnValue)
{
var cells = row.parentNode.childNodes;
for(var j=0; j < cells.length; j++)
{
if(typeof cells[j].style != 'undefined')
cells[j].style.backgroundColor = backgroundColor;
}
}
}
}
conditionallyFormatRowBackground('searchResultsId', 'accountLockedId', 'Yes',
'#F98181');
Bye
Davide
On Wed, Mar 12, 2008 at 9:08 AM, TRao <[EMAIL PROTECTED]> wrote:
>
> Hi
>
> I need to call the javascript function for each row in a <tr:table, when I
> write <th:script tag inside the <tr:table or <tr:forEach, it is simply
> ignored. View/Source doesn't have the javascript call. Whereas the
> <th:script outside the loop does apear in view/source. Here is sample
> code.
>
>
> <trh:script generatesContent="true" text="alert('Test')"/>
>
> <tr:table summary="Periodic table"
> id="searchResults"
> partialTriggers="button1"
> binding="#{searchResultsBackingBean.table}"
> value="#{searchResultsBackingBean.searchResults}" var="row"
> rows="3">
>
>
> <trh:script generatesContent="true" text="alert('Test')"/>
>
> <tr:column>
> <f:facet name="header">
> <tr:outputText value="locationName"/>
> </f:facet>
> <tr:inputText value="#{row.locationName}" />
> </tr:column>
> </tr:table>
>
> --
> View this message in context:
> http://www.nabble.com/Javascript-inside-%3Ctr%3Atable-or-%3Ctr%3AforEach-loop-tp16002526p16002526.html
> Sent from the MyFaces - Users mailing list archive at
> Nabble.com<http://nabble.com/>
> .
>
>