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

Issue in getting the value of apex page in controller class

HI.. I am unable get and set the values for a visualforce page in Controller class. I have the below visualforce code.


<apex:pageBlockTable value="{!ords}" var="a" id="detailTable">
<apex:column headerValue="Item Name">
<apex:inputField id="itemId" value="{!a.Item__c}" onblur="setItemName();"/>
<apex:inputHidden id="itemNameId" value="{!itemNameId}"/>
<apex:column headerValue="Price">
<apex:inputField id="priceId" value="{!a.Price__c}" onblur="setItemPrice();"/>
<apex:inputHidden id="itemPrice" value="{!itemPrice}"/>


 I am setting the values for itemNameId and itemPrice in javascript. Below is the code for that.

function setItemName(){
//alert('Before setting the setItemName');
for(i=0; i<100; i++) {
document.getElementById('soPage:theForm:blockId:detailTable:'+i+':itemNameId').value = document.getElementById('soPage:theForm:blockId:detailTable:'+i+':itemId').value;
function setItemPrice(){
for(i=0; i<100; i++) {
document.getElementById('soPage:theForm:blockId:detailTable:'+i+':itemPrice').value = document.getElementById('soPage:theForm:blockId:detailTable:'+i+':priceId').value;


Also am setting the values for these fields in Controller class like below.


    public String itemNameId {get;set;}
    public String itemPrice {get;set;}


But my problem is that unable to get the values for those fields in Controller. 


Please let me know how I can achieve the same problem.



Thanks in advance.

Edwin VijayEdwin Vijay

The variables ItemNameId and itemPrice should hold their values respectively... Debug these values and see what value they hold..


system.debug('Value of ItemNameId is'+itemNameId);