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
AK_SmithAK_Smith 

field value +1

Hello! I trying to add +1 to field with the code below. But did not succeed
 
<script>
       plus()
        var a = {!Activity__c.SF1_Attempts__c};
        function plus(){
        document.getElementById('page:form:Attempts').value = a + 1;
        }

</script>


Attempts : <apex:inputField id="Attempts" value="{!Activity__c.SF1_Attempts__c}" />

 
Ryan GreeneRyan Greene
Is it a number field? You can only add a number to a number field.
Also, you should NOT need to run JavaScript for this. As long as it is a number field you could go like this:

{!Activity__c.SF1_Attempts__c+1}
AK_SmithAK_Smith
Thank you! But I receive the error 

Error: Could not resolve field 'SF1_Attempts__c + 1' from <apex:inputField> value binding '{!Activity__c.SF1_Attempts__c + 1}' in page SF_Geo
AK_SmithAK_Smith
Content cannot be displayed: Invalid field SF1_Attempts__c + 1 for SObject Activity__c