0

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

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
    showAlert=true;
}

and on the page:

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

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.

0
function texttoNo(){

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

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

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

if(isNaN(parseInt(inputElem[i].value))){

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

 inputElem[i].value = 0;

 break;

}

} 

}

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

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

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.