1

Hello I have created a table in and it have 3 columns. Now i have to multiply first values in first two columns and get that result in third column.

my visualforce page

<apex:page controller="TestCalculationController">
   <apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" />
   <script type="text/javascript">
      var j$ = jQuery.noConflict();  
      j$(document).ready(function(){
      var i = j$('#tdi').val();  
      var tdd = j$('#tdd').val();
      function multiply(a,b) {
         return a*b ; } 
      var result= multiply (i,tdd) ;        
      j$('#res').val(result);  
      });    
   </script> 
   <apex:form>
      <table>
         <tr>
            <th>IntegerValue</th>
            <th>ConstValue</th>
            <th>Multiplied Result</th>
         </tr>
         <apex:repeat value="{!intList}" var="i">
            <tr class="inputs testclass" id='tr' >
               <td id ="tdi">{!i}</td>
               <td id ="tdd" >{!days}</td>
               <td id ="res"> </td>
            </tr>
         </apex:repeat>
      </table>
   </apex:form>
</apex:page>

and my controller

public class TestCalculationController {

            public integer days {
                get;
                set;
            }
            public List < Integer > intList {
                get;
                set;
            }

            public TestCalculationController() {
                intList = new List < Integer > ();
                days = 365;
                for (integer i = 20; i <= 30; i++) {
                    intList.add(i);
                }
            }
        }

1 Answer 1

2

There is no need of jquery to multiply two apex variables. you just need to use vf expression and multiply variable. your third "td" should be like this <td id ="res">{!(i * days)} </td>

1
  • Thanks, but is there any way to update the values using jquery ?
    – Srujan
    May 11, 2016 at 15:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .