I have a pageblock table to display the list of accounts and i have few buttons on my VF page like add row,delete etc.User can change the values in the columns and update the records. I want to add the values in a particular column(Quantity) and give an alert to user like ' sum of all the values after change ...' on clicking the buttons.

2 Answers 2


Assuming you are sending the users updates back to the controller, you could simply sum the values there and store in a property. You could then set another property to indicate the alert should be shown. That way you are decoupled from how you are rendering the data. It would be something like the following in the controller:

public Boolean showAlert {get; set;}
public double total {get; set;}

public PageReference update()
    // calc total

and on the page:

<apex:outputPanel rendered="{!showAlert}">
       alert('The new total is {!total}');

this is pretty simplistic, you'd also need to make sure to clear the showAlert flag when the page was submitted back in a way that didn't involve an update.

function texttoNo(){

 var Entirepageblock       =document.getElementById('{!$Component.page:theForm:showstate:pgBlkTable}');

var inputElem = Entirepageblock.getElementsByTagName("input");

for(var i=0; i<inputElem.length; i++) {


alert('Please enter only integer quantities.');

 inputElem[i].value = 0;





I have used this Javascript to get the values from each of the column dynamically .May be you may like to tweak this and sum all the columns and onclick of button validate

  • Hi Mohit,I am not able to iterate through all the pageblock table columns in VF page. Commented Nov 8, 2012 at 7:01

You must log in to answer this question.

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