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
krishna casukhela 7krishna casukhela 7 

How to pass inputHiddenfield value to apex controller

I have like this in my visualforce page
<apex:page controller="somename">

<apex:inputHiddenField value="{!firstname}" id="hiddenfield">
<apex:inputText value="{!firstName}" id="fname" onchange="GetFirstName(this);"  />

<apex:commandButton value="Save" action="{!SaveChanges}"/>
<script type="text/javascript">
  function GetFirstName(data)
      var hiddenvalue=document.getElementByID('data').value;
      alert(hiddenfield);  // am getting the correct value in alert
Now what I require is to have value of javascript variable(hiddenvalue) in my apex controller.
I want to do some action when I click the button so inside button code I need to have the value of javascript variable.
I hope I am clear.
without using action function or apex:param is there a way to do this?

pls let me know, urgent.

Vickal GuptaVickal Gupta
Try below code:
<apex:inputHidden value="{!fName}" styleClass="inputHidden" onChange="yourMethod();" />

    var hVal = j$('.inputHidden').val();
    alert('The inputHidden value = '+hVal.toString());

    //Your logic.......

Hope this will help.
krishna casukhela 7krishna casukhela 7
can u pls clarify, should it be on change of inputText?
also how do I get the value into my controller.?