[SalesForce] calling or using javascript function inside actionSupport

I have a pageBlockTable with rows, I want to call function from javascript or write a js function when I click on row.

<apex:pageBlockTable var="c" ...>
     <apex:column ../>
     <apex:column ../>
      <apex:actionSupport event="onRowClick" immediate="true" reRender="" >
           // call JS function ex. this.style.backgroundColor = 'yellow';
           <apex:param name="cId" value="{!c.Id}" assignTo="{!cId}"/>
      </apex:actionSupport>
</apex:pageBlockTable>

Best Answer

You need to use onsubmit event of the actionSupport and remove onRowClick from the pageBlockTable:

<script>
var lastRow;
function highlight(elem){
    if(lastRow != undefined)
        lastRow.style.backgroundColor = 'white';

    elem.style.backgroundColor = 'yellow';
    lastRow = elem;
}
</script>

<apex:pageBlock >
<apex:pageBlockTable value="{!list1}" var="item" rules="rows" id="myTable1">
    <apex:column value="{!item.id}" />
    <apex:column value="{!item.name}"/>
    <apex:actionSupport event="onRowClick" reRender="" onsubmit="highlight(this);">
        <apex:param name="cId" value="{!item.id}" assignTo="{!myStringValue}"/>
    </apex:actionSupport>
</apex:pageBlockTable>    
</apex:pageBlock>