You need to sign in to do that
Don't have an account?
Mahendiran Jayavarma
Sum the checked rows only
Hi,
I wants to sum the billable amount for checked rows only when clicking generate button.
Controller:
public class ActivityController
{
public PageReference Search() {
return null;
}
Task Task;
public Task getTask() {
if(Task == null) Task = new Task ();
return Task ;
}
Public Task[] getActivities()
{
return [Select id, subject,activitydate,owner.name,pro__Billable_Hrs__c,pro__Rate_Hrs__c,pro__Billable_Amount__c from Task];
}
}
Apex Code:
<apex:page controller="ActivityController" > <apex:sectionHeader title="Invoice Generate" /> <apex:form > <apex:pageBlock > <apex:pageBlockSection title="Search Task" columns="4" > <apex:inputField id="Taskstatus" value="{!Task.status}" style="width:150px;"/> <apex:commandButton value="Search" action="{!Search}"/> </apex:pageBlockSection> <apex:pageBlockSection title="Search Result" columns="1" > <apex:pageBlockTable value="{!Activities}" var="a" width="750"> <apex:column > <apex:facet name="header">Select</apex:facet> <apex:inputCheckbox value="{!a.Id}" /> </apex:column> <apex:column value="{!a.subject}" rendered="true"/> <apex:column value="{!a.owner.name}"/> <apex:column value="{!a.Billable_Hrs__c}"/> <apex:column value="{!a.Rate_Hrs__c}"/> <apex:column value="{!a.Billable_Amount__c}"/> </apex:pageBlockTable> </apex:pageBlockSection> <apex:pageBlockButtons > <apex:commandButton value="Generate"/> </apex:pageBlockButtons> </apex:pageBlock></apex:form> </apex:page>
Help me....
Thanks,
Mahendiran
you can write javascript function
function getCheckedRows(){
var obj = document.forms[0].elements;
var checkedIds;
for(var i=0;i<obj.lenght;i++){
if(obj.type=='checkbox' and obj.checked='true'){
checkedIds=checkedIds+"~";
}
}
document.forms[0].ids.value=checkedIds;
}
on