My visualforce page is

 <apex:variable value="0" var="rowNum"/> 
      <apex:dataTable value="{!templook}" var="item" style="margin-left:60px;"  cellpadding="5" cellspacing="6"   >
 <apex:column headerValue="Quantity">
                      **<apex:inputtext Value="{!item.Quantity__c}" onblur="multiplycal();" styleclass="quantity{!rowNum}"/>**
                   <apex:column headerValue="Unit Price($)">
                     <apex:inputtext Value="{!item.Price__c}" styleClass="price{!rowNum}" onblur="multiplycal();"/>
           <input type="hidden" value="{!rowNum}" class="values" name="values"/>  
 <apex:pageBlockSectionItem >          
                     <apex:outputLabel value="total($) :"/>
                     <apex:outputLabel value="" styleClass="sum"  style="width:78px;text-align:right;display:block;font-size:12px;color:#000000;" />

My javascript is:

<script type="text/javascript">
var j$ = jQuery.noconflict();
function multiplycal(){
    var values=$(".values").val();  
    var total = 0.0;

    for(var i=0;i<values;i++)
        var amtfield=trim($(".price"+i).val());       
        var quantity=trim($(".quantity"+i).val());
        total= parseFloat(total)+(parseFloat(amtfield) * parseInt(quantity));


function formatDoll(number) {
    var pip = number.toFixed(2).split(".");
    return pip[0].split("").reverse().reduce(function(acc, number, i, orig) {
        return  number+ (i && !(i % 3) ? "," : "") + acc;
    }, "") + "." + pip[1];

If I use apex:inputtext it is working fine. But my requirement is <apex:outputlabel Value="{!item.Quantity__c}" onblur="multiplycal();" styleclass="quantity{!rowNum}"/>. for this I can't use onblur since I'm using apex:outputlabel. Hence I should go with dom ready function.But don't have any idea.Help!!!!!!

  • can you give more detail on the objective and why your requirement is to use outputLabel? it looks like you want the user to enter a quantity value and then have the calculation done. – zjeh Dec 3 '12 at 22:37

Well not sure what you want to do but if you want to hook to the dom ready you have to do something like this

var j$ = jQuery.noconflict(); 
j$(document).ready(function() {
   // put all your js in here.
  • it doesn't work....:( – Eagerin Sf Dec 3 '12 at 12:03
  • 1
    Can you post the full js code? And the objective ? what you want to achieve? Additionally Can you check the javascript console for any errors? In chrome you can open the same by pressing CTRL+SHIFT+J – Avidev9 Dec 3 '12 at 12:17
  • Add "@gmail.com" after my username[to avoid spammers am not including the email here] – Avidev9 Dec 3 '12 at 12:30

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.