2 Replies Latest reply on May 11, 2006 12:40 PM by dempster

    How do I tell which form button was clicked

    SJColtsFn
      I have a CFForm with three buttons on it: a standard reset button, and two submit buttons that will perform different functions depending on which one was clicked. When I go to the action page, how can I tell which button was clicked in order to perform the correct action?
        • 1. Re: How do I tell which form button was clicked
          BKBK Adobe Community Professional & MVP
          <cfform>
          <cfinput name="s1" type="submit"...etc>
          <cfinput name="s2" type="submit"...etc>
          </cfform>

          On the action page, do

          <cfif isDefined("form.s1")>
          s1 submitted
          <cfelseif isDefined("form.s2")>
          s2 submitted
          </cfif>







          • 2. Re: How do I tell which form button was clicked
            dempster Level 1
            Or you can give the buttons the same name with a specific value:

            <input type="submit" name="formaction" value="Reserve Date">
            <input type="submit" name="formaction" value="Schedule Date">

            Form.formaction will return the value of the button clicked. Only thing to be careful about is if the user hits return in a text input box. That would submit the form without a value for formaction.

            You could handle that by requiring the button:

            <input type="hidden" name="formaction_required" value="Please select an action.">