# Call Function Only Once

**URL:** https://forum.kirupa.com/t/call-function-only-once/252828
**Category:** flash
**Created:** [February 24, 2008, 6:17am UTC](https://forum.kirupa.com/t/call-function-only-once/252828 "2008-02-24T06:17:17Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Pherank](https://avatars.discourse-cdn.com/v4/letter/p/4af34b/32.png) [@Pherank](https://forum.kirupa.com/u/Pherank)
#### Post date: [February 24, 2008, 6:17am UTC](https://forum.kirupa.com/t/call-function-only-once/252828/1 "2008-02-24T06:17:17Z")

</div>

I have a a submit button that when clicked does the following:

1. Runs a func called getCartValues() that gathers data
2. Validates some input text fields
3. Sends variables to a PHP script

Since the input field validation might catch a problem the user will have to resubmit after making changes. The problem is, getCartValues() increments the data if it gets run more than once, so I need it to run only the first time the submit button is clicked and not on the following clicks. Anyone know how to code this?
