+ Start a Discussion
anup ramanup ram 

Syntax error calling javascript with parameters in inputfield onblur



I am getting syntax error while passing parameters to javascript from inputfield onblur attribute.


I do not know why the error is resulting in.


Please help me with the solution.


I hope there is no apex controller required along with the visualforce page.



<apex:page standardController="Account" recordSetVar="accs" sidebar="false">

<script type="text/javascript">


  function computeTotal(quantityId, unitPriceId, totalId){

    var quantity = document.getElementById(quantityId).value;   

    var cost = document.getElementById(unitPriceId).innerHTML;       

    var totalPrice = quantity * cost;       

    document.getElementById(totalId).innerHTML = totalPrice;



  <apex:form >

    <apex:pageBlock >

      <apex:pageBlockTable value="{!accs}" var="acc">

        <apex:column headerValue="Quantity">


                   <apex:inputText id="quantity" onblur="computeTotal('{!$Component.quantity}','{!$Component.unitPrice}','{!$Component.total}');"/>



        <apex:column headerValue="Unit Price">

          <apex:outputText id="unitPrice" value="10"/>


        <apex:column headerValue="Total Price">

          <apex:outputText id="total"/>






Try this give Id's to all the parent components of Quantity, unitPrice, total. Then try to refer them by doing something like this.

{!$Component.thePageId.theFormId.thePageblockId.the PageBlockTable.theColumnId.quantity}

Hi Anup, 


I have tried your code in my org, It's working fine in my org.