function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

How to mul 2 textfields values in two col and display the value to the next col in Pageblocktable ?

I am new to coding, so please bear with me .....


my Visualforce code has two parts the first half is success and in my Second part i have to use JAVASCRIPT to get the Total Price by Multiplying two values from two Different fields 


for eg : by calculating the price(5)*Qty(5) =Total(25)  should be displayed , i messed up somewhere and don’t know wt to do next ....



Please Help and suggest me ...... 


My VF code as follows:


<apex:page Controller="opty2proposal" id="page" >

<script type="text/javascript">

function updateRate()

var rat=document.getElementById('{!$Component.frm.pb.pbs.pbt.pbsi.rate}');
var discP= document.getElementById('{!$Component.frm.pb.pbt.col1.pbs1.pbsi1.discPcrnt}'); 

document.getElementByID("discRate").value = rat*discP;


<apex:form id="Header" >
<form name="PrintInformationTop">
<input type="button" name="PrintInformationTop" value=" Print" onClick = "window.print()" />

<apex:sectionHeader title="Multiple Records"/>
<apex:pageBlock title="Proposal header">
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}" />


<apex:pageBlockSection >

<apex:pageBlockSectionItem id="Opportunity"> 
<apex:outputLabel value="Opportunity Name" for="OpportunityName" />
<apex:inputText id="OpportunityName" value="{!}" size="40"/> 

<apex:pageBlockSectionItem id="Account"> 
<apex:outputLabel value="Account Name" for="AccountName" />
<apex:inputText id="AccountName" value="{!}" size="40"/> 

<apex:pageBlockSectionItem id="Contact" >
<apex:outputLabel value="Contact Name" for="ContactName"/> 
<apex:selectList id="leadName" value="{!contactName}" size="1" multiselect="false">
<apex:selectoptions value="{!ContactList}" />


<apex:pageBlockSectionItem >
<apex:outputLabel value="TextArea" for="TextArea"/>
<apex:inputTextarea id="TextArea" value="{!Description}"/>


<apex:form id="frm">
<apex:sectionHeader title="Proposal Line Code" subtitle="AddProduct" />

<apex:pageBlock title="AddrowDynamically" id="pb" >

<apex:pageBlockButtons > <apex:commandButton value="Save" action="{!save_line}" />


<apex:pageBlockSection id="pbs" >
<apex:variable value="{!0}" var="rowNumber" />

<apex:commandButton value="Add" action="{!addNewObject}" reRender="newItems,panelWithVar,pbs" immediate="true"/>

<apex:outputPanel id="panelWithVar">
<apex:variable value="{!0}" var="rowNumber" />


<apex:pageBlockTable value="{!objectsToInsert}" var="item" id="pbt">
<apex:column width="5%">

<apex:commandButton action="{!removeNewObject}" value=" X " reRender="newItems,panelWithVar,pbs">
<apex:param name="p1" value="{!rowNumber}" assignTo="{!numberOfRowToRemove}"/>


<apex:column >
<apex:outputLabel value="Product Name" for="ProName"/>

<apex:selectList id="ProName" value="{!productName}" size="1" multiselect="false">
<apex:selectoptions value="{!ProductList}" />


<apex:column headerValue="Proposal Line Name">

<apex:inputField value="{!item.Name}"/>


<apex:column headerValue="Price">

<apex:pageBlockSectionItem id="pbsi" >
<apex:inputField id="rate" value="{!item.Price__c}" />


<apex:column headerValue="Quantity" id="col1" >

<apex:pageBlockSectionItem id="pbsi1">
<apex:inputField id="discPcrnt" value="{!item.Quantity__c}" onchange="updateRate();"/>


<apex:column headerValue="Total" >

<apex:pageBlockSectionItem >
<apex:outputText id="discRate" rendered="{!check}"/>

<apex:column headerValue="Description">
<apex:inputField value="{!item.Description__c}"/>






and my Controller :


public class opty2proposal{

public String getIsEditable() {
return null;

public Boolean check{ get; set; }

public List<Proposal_Line__c> objectsToInsert { get; set; }
public Integer numberOfRowToRemove { get; set; }

public String ProductName{get;set;}
public string test{get;set;}

Opportunity opty;
Account account;
Contact contact;

public String ContactName{get;set;}
public string Description{get;set;}
public Integer Quantity{get;set;}
public Integer price{get;set;}
public Integer total{get;set;}

public opty2proposal() {

objectsToInsert = new List<Proposal_Line__c>();
objectsToInsert.add(new Proposal_Line__c());

opty = [select id, name, accountId, OwnerId, Description from Opportunity where id = :ApexPages.currentPage().getParameters().get('id')];

public PageReference addNewObject(){

Proposal_Line__c newObject = new Proposal_Line__c();

return null;

public PageReference removeNewObject(){


return null;
public List<SelectOption> getProductList() {
Product2[] products = [SELECT Id,name FROM product2 LIMIT 10 ];
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('- None Selected - ','- None Selected - '));
for (product2 acc : products) {
options.add(new SelectOption(acc.Name,acc.Name));
return options;}

public PageReference save_close()

Proposal_Line__c objectsToInsert=new Proposal_Line__c(
insert objectsToInsert;
PageReference home = new PageReference('/home/home.jsp');
return home;

public Opportunity getOpty() {
return opty;


public Account getAccount(){
account=[select id, name,OwnerId from Account where id=:opty.accountId];
return account;

public List<SelectOption> getContactList() {
Contact[] Contacts = [SELECT Id,Firstname,Lastname,name FROM Contact Where Accountid = :opty.accountId ];
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('- None Selected - ','- None Selected - '));
for (Contact con : Contacts) {
options.add(new SelectOption(con.Name,con.Name));
return options;

public void save() {

Proposal_Header__c ph=new Proposal_Header__c(
insert ph;
public PageReference save_line() {

insert objectsToInsert;
PageReference pg=New PageReference('/006/o');
return pg;





Your javascript is attempting to add the two elements together, not the values contained by those elements.  You need to use the 'value' attribute of the element to get at the actual numbers.


Check out this page for an example:


Thanks for the Reply ....  it was helpfull


I am missing somthing and its still not working .....


Can u please post the Correct CODE for my Program..... Please ....


Thanks in Advance ....