You need to sign in to do that
Don't have an account?
Austin Davis 8
I need to pass a simple string to the controller, but none of the methods I've tried seem to be working.
Nothing seems to be working for me for trying to pass just a single variable between a VisualForce Page and its Controlller.
Attempt 1:
Attempt 2:
If I try a normal actionfunction with set off by an onclick event then the parameter does not pass. I have been informed that I need to have the rerender attribute assigned. However, when I put in the rerender attribute I get the following error:
Uncaught SyntaxError: Unexpected token :
Any help is very much appreciated. Thanks.
Attempt 1:
public String selectedItem {get; set;} <apex:form> <apex:inputhidden value="{!selectedItem}" value="" id="itemID"/> </form> <script type="text/javascript"> function clickedItem(s) { jQuery("[id*='itemID']").val(s); alert('{!selectedItem}'}; } </script> <tr onclick="clickedItem"> //................................ </tr>
Attempt 2:
public String selectedItem {get; set;} public PageReference clickedItem(){ selectedItem = ApexPages.currentPage().getParameters().get('itemID'); System.Debug('Selected Item = ' + selecteditem); return null; } <apex:form> <apex:actionFunction action="{!clickedItem}" name="setSelectedItem"> <apex:param name="itemID" value="" assignto="{!selectedItem}"/> </apex:actionFunction> <apex:form>
If I try a normal actionfunction with set off by an onclick event then the parameter does not pass. I have been informed that I need to have the rerender attribute assigned. However, when I put in the rerender attribute I get the following error:
Uncaught SyntaxError: Unexpected token :
Any help is very much appreciated. Thanks.
This code works. Look at the positions of the "apex:form" tags.
Alain