You need to sign in to do that
Don't have an account?
Btuitasi1
Field update on command button click
I am trying to create two buttons that inserts Up and Down on a record by clicking a command button. Here is my code so far:
VF Page:
Extension:
Any ideas on how to make this work? Also, I'm trying to figure out how to implement unique votes by user.
Thanks!
VF Page:
<apex:form id="votingSection"> <apex:pageBlock mode="edit"> <apex:pageBlockButtons location="bottom"> <apex:commandButton styleclass="btn-lg btn-data" value="Vote Up" action="{!voteUp}" reRender="votingSection"/> <apex:commandButton styleclass="btn-lg btn-data" value="Vote Down" action="{!voteDown}" reRender="votingSection"/> </apex:pageBlockButtons> </apex:pageBlock> </apex:form>
Extension:
public class detExt2 { private final my_object__c myObject; public detExt2() { myIdea = [SELECT Id, Vote_Button__c, Name FROM my_object__c WHERE Id = :ApexPages.currentPage().getParameters().get('id')]; } public my_object__c getObject() { return myObject; } public PageReference voteUp() { myIdea.Vote_Button__c = 'Up'; update myObject; return null; } public PageReference voteDown() { myIdea.my_object__c = 'Down'; update myObject; return null; } }
Any ideas on how to make this work? Also, I'm trying to figure out how to implement unique votes by user.
Thanks!
What is not working in your VF?
Regards.