Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

below is my code:

public with sharing class myController {
    public String passedInString { get; set; }

    public PageReference passedInValue() {
        system.debug('Passed in value: '+passedInString);
        return null;
    }    
}

My VF:

<apex:page controller="myController">
    <apex:includeScript value="{!URLFOR($Resource.myStatic, '/js/jquery-2.1.1.min.js')}"/>  
    <p>Click Me!</p>
    <button type="button" id="addScnt" onclick="setHidden()">Pass Input</button>
    <apex:form id="myForm">
        <apex:inputHidden value="{!passedInString}" id="myHiddenField"/>
        <apex:actionFunction name="setHidden" action="{!passedInValue}" rerender="myHiddenField"/>
    </apex:form>
    <script type="text/javascript">
        j$ = jQuery.noConflict();
        function setHidden() {
        var copyOfStr = 'Test string';
        document.getElementById('{!$Component.myForm.myHiddenField}').value = (copyOfStr);
    }   
    </script>     
</apex:page>

When the button is clicked I expect the javascript function to be run and the value of the hidden input set. Inspecting the log in developer console I was expecting the passedInValue action method in the actionfunction to fire as well showing the debug statement of the passedInString value but that didn't happen.

share|improve this question

1 Answer 1

up vote 0 down vote accepted

Both your action function and your own javascript function are called "setHidden".

Call your actionFunction something else and then call that from your own defined setHidden function.

share|improve this answer
    
Thanks ForceHero! –  sw6 - KTBFFH Jan 21 at 16:56

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.