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}"/>

1 Answer 1


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

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

    elem.style.backgroundColor = 'yellow';
    lastRow = elem;

<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}"/>
  • Thank you So much, you are very helpful person :).. I tried onComplete="highlight(this);", but it highlight column.. Thank you again Mar 31, 2014 at 15:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .