I want to pass the java-script value to controller.I am using repeat on VF page.
VF page
<apex:repeat value="{!listAdj}" var="Adj" id="hrs">
<td><div class="requiredInput"><div class="requiredBlock"></div>
<apex:inputField id="decimal" value="{!Adj.Hours_Decimal__c}" onchange="setHidden5(this);" >
</apex:inputField>
</div></td>
<apex:inputField id="hours" value="{!Adj.Hours__c}" />
<apex:inputField id="decimal" value="{!Adj.Hours_Decimal__c}" onchange="setHidden5(this);"/>
</apex:repeat>
Javascript code
function setHidden5(element){
//split the id of the inputField by ':' and then use the 5th index in the array to exact position of the inputField in the apex:repeat.
var idArray = element.id.split(':');
var hiddenRep1 =document.getElementById("thePage:form:hrs:hrs:"+idArray[4]+":decimal");
var hiddenRep2 = document.getElementById("thePage:form:hrs:hrs:"+idArray[4]+":hours");
if(element.value.length >=1){
document.getElementById("thePage:form:hrs:hrs:"+idArray[4]+":hours").disabled = true;
**hiddenRep2.value=hidden1.value;**
}
}
}
I want to pass the hiddenRep2.value to controller.How to pass that.
Hidden2.value is same as hidden1.value + some addition subtraction.i dont know how to pass that value.
Can someone me sort out this.
Thanks
Best Answer
There are multiple solutions for this question.
1. Use of hidden field
You can define an apex variable and associate it in a hidden input field on the visualforce page. Then set a javascript variable to this field an reference it in controller:
Apex class:
Visualforce page:
2. Use of apex:param