0

I want to pass a javascript variable into the controller of my visualforce page. Using <apex:param value="JAVASCRIPTVARIABLE" /> is throwing me an error because it expects JAVASCRIPTVARIABLE to be an exposed property of the controller. Please tell me how to pass the value of JAVASCRIPTVARIABLE to a variable in the controller. Thanks in advance.

Prajith
  • 1,559
  • 1
  • 18
  • 37

1 Answers1

3

Here is a SFSE link which talks about how to pass javascript values to controller. It explains how to use <apex:param also. Hope this helps.

Snippets

<!-- A new value will be set to the apex:param -->
<apex:actionFunction name="passStringToController" action="{!myMethod}" rerender="myHiddenField">
    <apex:param name="p1" value="" assignTo="{!myString}" />
</apex:actionFunction>

<!-- Here we can directly access the action function per name and assign a variable value -->
<apex:commandButton value="Test me" onclick="passStringToController('new value'); return false;" />
Saroj Bera
  • 14,699
  • 2
  • 17
  • 35