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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.