### [How to Automatically Submit a Form with a Field Choice](https://wpforms.com/developers/how-to-automatically-submit-a-form-with-a-field-choice/)

**Published:** May 12, 2023
**Author:** Umair Majeed

**Excerpt:** Would you like to automatically submit a form based on a field choice? This tutorial will show you how easy this is by using a little PHP and CSS. 

**Content:**

Would you like to create a simple feedback form that submits automatically when users make a selection? This is perfect for quick “Was this helpful?” surveys where users can respond with a single click. By automatically submitting after selection, you can maximize response rates by making the process effortless for users.

This guide will show you how to create a streamlined feedback form that submits instantly when users make their choice.

## Setting Up Your Form

First, create a new form with this structure:

1. A **Layout field** to organize your options
2. Two **Checkbox fields** – one in each Layout column for “Yes” and “No” options
3. A **Hidden field** to capture the page title

![begin by creating your form and adding 2 checkboxes and a hidden field](https://wpforms.com/wp-content/uploads/2023/05/wpforms-submit-automatically-create-form.jpg)If you need help with creating your form, [please review this form creation guide](https://wpforms.com/docs/creating-first-form/ "Creating Your First Form").

## Configuring the Icon Choices

For a polished look, we’ll use icon choices for the Yes/No options. Configure your checkbox fields with these settings:

Yes Checkbox

- Enable **Use icon choices**
- **Icon**: face-smile
- **Icon Color**: #066aab
- **Icon Size**: Large
- **Icon Choice Style**: Classic
- **Hide Label**: enabled

No Checkbox:

- Same settings but with face-frown icon

![set your checkbox to use icon choices](https://wpforms.com/wp-content/uploads/2023/05/wpforms-icon-choices-submit-automatically.jpg)## Adding a Smart Tag to the Hidden Field

For the **Hidden Field**, we’re going to add the Smart Tag to capture the page title when the form is submitted. To learn more about built-in Smart Tags with the WPForms form builder, [you can review this documentation](https://wpforms.com/docs/how-to-use-smart-tags-in-wpforms/ "Using Smart Tags").

We’ve added the Smart Tag {page\_title} to **Default Value** of the **Hidden Field**.

![add the page title smart tag to the hidden field default value](https://wpforms.com/wp-content/uploads/2023/05/wpforms-hidden-field-smart-tag.jpg)## Automatically submit the form

Now it’s time to add the snippet to your site. If you need help in how to add snippets to your site, [please check out this tutorial](https://wpforms.com/developers/how-to-add-custom-php-or-javascript-for-wpforms/ "How to Add Custom PHP or JavaScript for WPForms").

This snippet will only run on the form ID **3046**, when either of the **Checkbox** fields are checked, it will trigger this function and automatically submit the form.

You’ll need to update this form ID to match your own form ID. If you need assistance in finding your form ID, [please review this guide](https://wpforms.com/developers/how-to-locate-form-id-and-field-id/ "How to Locate Form ID and Field ID").

## Styling the Form

Add this CSS to style your form appropriately. Update the form ID (3046) and field IDs (3 and 4) to match your form:

This CSS hides unnecessary elements and positions your icons perfectly. For help in adding CSS, review our guide on [adding CSS code to your WordPress site](https://wpforms.com/developers/how-to-add-custom-php-or-javascript-for-wpforms/).

You’ll need to update the form ID for these CSS rules to make sure that it’s targeting the correct form and field IDs.

Our form ID for the purpose of this documentation is **3046**. Our first checkbox is the field ID **3** and the second checkbox is field ID **4**.

Now whatever option your visitors selects, the form will automatically submit.

![with this snippet, once the user makes a selection it will automatically submit a form](https://wpforms.com/wp-content/uploads/2023/05/wpforms-automatically-submit-the-form.jpg)And that’s it! Now when your visitors click either icon choice, the form will automatically submit. Would you like to show or hide your submit button conditionally based on an answer from your form? Please check out the tutorial on [How to Conditionally Show the Submit Button](https://wpforms.com/developers/how-to-conditionally-show-the-submit-button/ "How to Conditionally Show the Submit Button").

## Reference Action

[wpforms\_wp\_footer\_end](https://wpforms.com/developers/wpforms_wp_footer_end/ "Using the wpforms_wp_footer_end action")

**Categories:** Extending

**Tags:** PHP

---

