Yes, I know, this has already been answered, but I donot understand the answers or the methods.
I have a var of type STRING, say, myStr
, I want to pass it to my controller method myMethod()
. (it can also accept a string argument if needed).
CLARIFICATION : myMethod
is a function in my CONTROLLER. JSCalltoController
is the JS function that is called on clicking the button (THIS IS WITH ACTIONFUNCTION)
Sorry if there was any confusion.
What do I do?
Things I've tried :
1. Direct :
<button type="button" onclick="myMethod(myStr)">Enter</button>
The method is not called. I'm using system.debug to check whether the code reaches the function.
2. Actionfunction
<button type="button" onclick="JSCalltoController()">Enter</button>
<apex:actionFunction action="{!myMethod}" name="JSCalltoController">
<apex:param name="myStr" assignTo="{!myStrController}" value="" />
</apex:actionFunction>
The above, ofcourse, fails.
If someone could demonstrate how to use this, It'd be nice.
There is a distinct lack of adequate (and in simple enough language) documentation/examples for many Visualforce elements.
**UPDATE : ** whole page is here : http://codepad.org/baQewaaA part of controller is here : http://codepad.org/fJsEu6TJ.
I am very frustrated right now, hours of searching and still no results. Anyone who can help me understand exactly WHAT is going wrong here, would win my lifelong gratitude.
<apex:param name="NumberedString" assignTo="{!controllerValue}" value='myStr' />
?? – fraglord Aug 29 '16 at 12:10