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
Colin LoretzColin Loretz 

Issue sending variables to a controller

I'm using javascript to set a value in an apex:inputHidden field. That value is not passed on to the controller even though it is bound to a variable in the controller. 

 

Javascript: 

 

        document.getElementById('timeEntry:j_id82:0:j_id86:j_id88:j_id89:selectedDay').value = currentDate;

 

Visualforce:

<apex:inputHidden id="selectedDay" value="{!selectedDay}" />

 

APEX:

  public String selectedDay { get; set; }

 

I used javascript alert() statements to check the value of the apex:inputHidden field and the value of currentDate is being set properly. However, when using selectedDay in my controller, it is null. The inputField has the value but the controller is not aware of the field's contents.

 

Am I missing a step in here somewhere that allows this to happen? 

 

Thanks. 


Best Answer chosen by Admin (Salesforce Developers) 
Ron HessRon Hess

i think you are missing an action, but i don't see enough code to determine.

 

here is a working example of using inputHidden to pass fields from a form into a controller.

 

http://wiki.developerforce.com/index.php/Sites_And_Captcha

 

 

hope this helps.

All Answers

Ron HessRon Hess

i think you are missing an action, but i don't see enough code to determine.

 

here is a working example of using inputHidden to pass fields from a form into a controller.

 

http://wiki.developerforce.com/index.php/Sites_And_Captcha

 

 

hope this helps.

This was selected as the best answer
Cool_DevloperCool_Devloper

Hello Colin,

 

I saw another post by you regarding Tree structure with the number of levels not fixed.

 

Did you get any solution for that??

 

Please let me know as i am working on exactly the same requirement!!

 

Thanks,

Cool_D 

Cool_DevloperCool_Devloper

Hello Ron,

 

Can i pass values into Hidden fields if my value is inside a Repeat??

 

In this case, i get the ID dynamically generated ... so i am not able to pick the exact ID.

 

Is there a solution to this problem??

 

Thanks,

Cool_D