My visualforce page is
<apex:outputpanel>
<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>
<apex:column headerValue="Unit Price($)">
<apex:inputtext Value="{!item.Price__c}" styleClass="price{!rowNum}" onblur="multiplycal();"/>
</apex:column>
</apex:datatable>
<input type="hidden" value="{!rowNum}" class="values" name="values"/>
</apex:outputpanel>
<apex:pageBlockSectionItem >
<apex:outputLabel value="total($) :"/>
<apex:outputLabel value="" styleClass="sum" style="width:78px;text-align:right;display:block;font-size:12px;color:#000000;" />
</apex:pageBlockSectionItem>
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));
}
alert(total);
$('.sum').html(formatDoll(total));
}
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];
}
</script>
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!!!!!!