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
SamCousinsSamCousins 

Change <apex:param> value with javascript

I have the following:
<apex:column headerValue="Contact" headerClass="ct" >

    <apex:inputField value="{!c.Contactid}" id="inputField"/>
    <apex:inputHidden id="hdnField" value="{!contactId}" />

    <apex:commandLink value="+" styleClass="btn" style="color:red;font-size:15px;"  onclick="setVar();" action="{!updateCase}" >

        <apex:param name="caseId"
                    value="{!c.Id}"
                    assignTo="{!caseId}" />

        <apex:param name="contactId"
                    value="{!contactId}"
                    assignTo="{!contactId}" />                            

    </apex:commandLink>       

</apex:column>
I'm trying to set the apex:param with the name contactId to the value of my apex:inputHiddenfield so I can pass that value to my controller when I click the command button. inputHidden is set correctly, but I can't work out how to link the param to the inputHidden value attribute?

Does anybody have any ideas?
 
Best Answer chosen by SamCousins
Shashi PatowaryShashi Patowary
Hi Sam,

You can directly assign the hidden value into 'value' parameter of apex param and it will be available in the controller.

Alternately  you try this -
<apex:page standardController="Contact" extensions="ContactController">  
    <apex:form >
    <script>
    function SetJSValue() {
      var a = document.getElementById('{!$Component.hdnField}').value;

      SetHiddenValue(a);
    }
    </script>
     <apex:actionFunction action="{!processButtonClick}" name="SetHiddenValue" reRender="">
        <apex:param name="myParam" value=""/>
    </apex:actionFunction>

        <apex:commandLink value="Send Hidden Value"  onclick="SetJSValue()" rerender="hiddenBlock">
           
        </apex:commandLink>

      
          <apex:inputHidden id="hdnField" value="{!contact.firstname}" />
  

    </apex:form>
</apex:page>

 
public PageReference processButtonClick() {
    string passedParam1 = Apexpages.currentPage().getParameters().get('myParam');
        System.debug('passedParam1 ----------------------> '+passedParam1 );
        return null;
    }

Please let me know if this helpful.

regards,
Shashi