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
SalesRedSalesRed 

How to get a value from a javascript variable in Visualforce

Hello,  I wish to use the following scenario but I'm not 100% sure if ti will work.

 

- I call a javascript function from a href ink in my visualforce page.

- within the javascript function a variable is set.

- in an apex:outputLabel  (for starters but I will need ot access the variable elsewhere)  the value comes from the variable I set in the javascript function.

 

Can this scenario be done?

 

I note the scenario can be done the opposite way around (Javascript can get a value from a visualforce component)   View $Component in http://www.salesforce.com/us/developer/docs/pages/Content/pages_variables_global.htm  but can the scenario I require be carried out?

 

Thanks in advance.

 

JanitaB2JanitaB2

You might try putting a component on your VF page that is not visible.  Set that value in javascript, and access it from VF.  I haven't done exactly this, but it should work the same as if you are changing a value on the page from javascript.

SalesRedSalesRed

Hi JanitaB2,  Thanks for your suggestion.  The part I'm not sure of is how do I access the variable set via Javascript?

I know how to set a variable in Javascript but not how to access one which was set by javascript.

 

Thanks,