You need to sign in to do that
Don't have an account?
how to pass values of javascript variable to controller?
hey Ragjesh your code helped me a lot but am getting null value in my controller can you suggest me the exact solution of this problem
here is my code:
Apex Code: <apex:actionFunction name="sendTimeStamp" action="{!sendTimeStamp}"> <apex:param name="x" value="x" assignTo="{!timeStampValue}" /> </apex:actionFunction> javascript code: timeStamp = Number(new Date()); sendTimeStamp(timeStamp); controller code: public string sendTimeStamp() { return timeStampValue; } public string timeStampValue{ get { timeStampValue = timeStamp; return timeStampValue; } set;}
please Help me i am newbie in salesforce
i dont know where i am making mistakes?
Hello,
Please use the following code. In the rerender property of actionFunction please specify the id of section which you want to rerender.
All Answers
If you check the forum you will find many readymade code for this purpose:-
I found this 1 just check and compare what are u doing different:-
VF Coded:-
<apex:page controller="OurTest">
<apex:form>
<apex:actionFunction name="ShuffleByID" action="{!ShuffleByRecordID}" rerender="out"/>
<apex:outputPanel id="out">
<apex:pageBlock >
<apex:pageBlockTable value="{!studentListLongArr}" var="enrollment" rendered="{!EnrollmentListSize > 0}">
<apex:column >
<apex:pageBlockTable value="{!enrollment.Registered_Student__r}" var="stulist">
<apex:column >
<apex:facet name="header">
<apex:commandLink onclick="ShuffleByID();return false;" action="{!doSort}" rerender="out">Record ID
<apex:param name="sortField" value="{!stulist.Name}" assignTo="{!YourName}"/>
</apex:commandLink>
</apex:facet>
<apex:outputLink value="{!stulist.id}" target="_top">{!stulist.Name}</apex:outputLink>
</apex:column>
</apex:form>
</apex:page>
Controller Code:-
public class OurTest()
{
public string YourName {get;set;}
public OurTest()
{
system.debug('++++++' +YourName);
//now you will get the value foYourName which you are passing from VF param tag.
}
// Rest of the code can be put here
}
Hi,
You can pass the variable to controller by using the below code snippet.
Below is the sample code to work around on this.
<apex:inputhidden value="{!Propval}" id="hdnobj"/>
<script>
var crtUrl = "{!$CurrentPage.URL}";
document.getElementById('pageid:formid:hdnobj').value = crtUrl;
</script>
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
is there any way to pass the javascript variable values to my controller without using concept opf url.......
please suggest me a solution based on my requirement.........
Hello,
Please use the following code. In the rerender property of actionFunction please specify the id of section which you want to rerender.