i have written vf and apex as below code mentioned and i am unable to gt the output:- enter image description here


function checkAllOrNone(allOrNoneCheckbox) {
    var container = allOrNoneCheckbox;
    while (container.tagName != "TABLE") {
        container = container.parentNode;
    var inputs = container.getElementsByTagName("input");
    var checked = allOrNoneCheckbox.checked;
    for (var i = 0; i < inputs.length; i++) { 
        var input = inputs.item(i);
        if (input.type == "checkbox") {
            if (input != allOrNoneCheckbox) {
                input.checked = checked;
<apex:form id="frm">
    <apex:pageBlock >
        <apex:pageBlockButtons location="top">
            <apex:commandButton value="Search" action="{!searchprts}" reRender="product-table" />
        <apex:pageBlockSection id="product-table" columns="1">
            <apex:pageBlockSectionItem >
                <apex:outputLabel value="Name" />
                <apex:inputText value="{!name}" />
            <apex:pageBlockTable value="{!Products}" var="c">
                <apex:column >
                    <apex:facet name="header">
                        <apex:inputCheckbox id="chkbox" onclick="checkAllOrNone(this)"/>
                    <apex:inputCheckbox />
                <apex:column >
                    <apex:facet name="header">Name</apex:facet>
                <apex:column >
                    <apex:facet name="header" >amt</apex:facet>
                    <apex:outputText id="id1" value="{!c.amt__c}"/>
                <apex:column >
                    <apex:facet name="header">Qnty</apex:facet>
                    <apex:inputField id="id2" value="{!c.q__c}"/>
                <apex:column >
                    <apex:facet name="header">Total </apex:facet>
                    <apex:outputText id="id3" value="{!ttl }"/>


public with sharing class Ctrl_ContactSearch
    public List<Product2> Products { get; set; }
    public String name { get; set; }
    public decimal total = 0;

    public Ctrl_ContactSearch()
        total = 0;
        Products = new List<Product2>();

    public PageReference searchprts()
        Products = [select Id,Name,amt__c,q__c from Product2 where Name = :name];

    public void ttl() {
       ttl = amt__c*q__c ;

Also i would like to store the output in other fields of custom object.


Visualforce can't find the property ttl because you do not have a getter method available. You would need to change

public void ttl()


public void getttl()

or store the value in an instance variable with synthesized getters and setters (you already have one called total that you aren't using):

public Decimal ttl { get; set; }
  • 1
    Haha getttl() totally looks like a typo. Probably a marginal improvement to use getTtl().
    – Adrian Larson
    Mar 14 '18 at 21:03
  • I wanted to avoid the variable-naming-and-nomenclature rabbit hole. Can't believe we don't have a decent Apex linter yet.
    – David Reed
    Mar 14 '18 at 21:23
  • 1
    I just meant three lower case ts in a row. Property syntax definitely superior here.
    – Adrian Larson
    Mar 14 '18 at 21:49
  • i tried with below changes but still i am not getting the result as multiple of two fields values containing one input and output text:- <apex:column > <apex:facet name="header">Total </apex:facet> <apex:actionSupport action="{!total}" event="onblur" reRender="frm"/> <apex:outputText id="id3" value="{!ttl}"/> </apex:column>
    – vijay
    Mar 15 '18 at 8:43
  • Comments are not for iterative debugging. You're welcome to ask a new question if you need assistance with a different issue.
    – David Reed
    Mar 15 '18 at 11:55

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.