I can see how your solution works, but there is a semantic element created for exactly what you want: <optgroup>. Whatever your solution, I’d encourage you to use that instead.
Searching for “contact form 7 optgroup” you’ll discover that other people are looking for the same thing you are and trying to implement <optgroup> to do it. Here’s one answer that includes both a javascript solution and a plugin hack (probably not a good idea). Probably the better solution I’ve found is this one. It’s a javascript to replace Contact Form 7 select options with the optgroup element using a specified syntax.
That final solution should probably remain stable even if CF7 adds optgroup support down the road.
Related Posts:
- Contact Form 7 plugin refreshing page on submit [closed]
- Contact form 7 select box different value-text than content-text in option [closed]
- How to disable autocomplete for inputs in contact form 7? [closed]
- Download any file after submitting a form [closed]
- Contact Form 7 Get Image Function [closed]
- Is there a way to embed a Google Docs form in a page without using plugins?
- WordPress contact form 7 to show the form dropdown menus as like [closed]
- How do I add the same contact form to multiple wordpress sites and capture the response in one place or database?
- How can I implement radio buttons with icons in Contact form 7?
- Hide button after form submit and save state to localstorage
- How to send custom mail when a user complete a specific form
- get/show Last ID
- Can’t edit Contact Us form on front page
- Plugin Beauty Contact Popup Form with while loop
- how to show selected options drop down menu values in attributes field in after saving post.php
- Issue using form in Google app in mobile
- Missing Contact Form/Form Default Plugin in WordPress
- How to get current post ID in Contact Form 7 wpcf7_before_send_mail hook action
- shortcode doesn’t work
- Template plugin for blog posts? [closed]
- Customize the Sorting Dropdown in WooCommerce
- Is there any good tutorial to write custom login, registration and password recovery forms? [closed]
- Server side validation for Contact Form 7 [closed]
- WordPress plugin form not saving data
- jQuery Plugin to use WordPress functions in AJAX request
- Add form fields dynamically on button click
- How to trigger $_GET request within admin plugin page?
- Retrieving a Value from a wp-database
- Custom CSS for plugin form
- Form doesn’t submit on second submit call
- WP plugins for building a database?
- Custom form action to handle data inside a plugin
- Image upload and other options in the same plugin settings form?
- When using Simple Fields plugin, how do I pull the information out of the database to display on a page?
- Creating an online questionnaire form – by Importing the questions from a spreadsheet?
- Using a custom plugin to capture input data via Ajax and PHP
- Getting value from dymanic text variable into Contact Form 7
- How to escape the tailwindcss responsive syntax when using with contact form 7? [closed]
- I want to auto populate data in three fields if one drop down is selected
- Submit page limited in time to upload image
- Ajax fail and get 504 error
- How to insert HTML/JavaScript form into WordPress page? [closed]
- Make a form that will send email to all the authors in selected category [closed]
- How to fetch form data and show it to my page?
- Submit custom form from post content and execute in plugin
- Char limit on custom blog-post form? [closed]
- easy steps to make front end form without plugin
- Form that generates an ID for the customer
- Submit Form data to another page via Ajax (WordPress Way)
- Editing a text file from plugin menu
- Ajax Plugin Not Echoing Response
- Contact Form 7 – Show image on successful send? [closed]
- Send email to multiple addresses on Contact Form 7, but exclude personal details on all but one
- Creating a form and displaying entry data as a table
- Storing The Data Collected by Ninja Forms into Another (custom) Database [closed]
- Custom form not showing in correct place on page
- Call another page in forms
- Echo out element to another page.
- How to Use the Filter “sidebar_login_widget_form_args”
- Add a “default sorting” menu to child store pages
- Select Form Element Not Saving from Plugin Options
- Contact Form 7 Plugin emails not being received by some accounts
- Using AJAX to run SQL statement and populate dropdown
- Looking for a simple checkout plugin [closed]
- Redirect plugin after form submit or show errors
- Making a Contact Form 7 calendar entry “required” [closed]
- acceptance_as_validation: on is not working Contact form 7 [closed]
- Contact Form 7 is not redirecting the “Thank-You” page with the removal of CSS and JS of plugins
- get wpforms ID value from ACF text field
- User loggedin as Subscriber form not sending
- How to create a form where you can select multiple recipients, based on a list of website users?
- WordPress search input in database, to edit information via form and update the database
- WPForms Custom Redirect not working
- Elementor contact form doesn’t work: “Oops! I cannot send this email!”
- Load google font script based on optgroup label selected
- Why is my form going to frontend on html form submission present on the php files inside my custom plugin?
- Could someone maybe point me in the direction of a decent tutorial on how to create a wordpress plugin that is compatible with another plugin please?
- How to submit custom form data using ajax to HubSpot form?
- Page takes on two different formats
- How can I automatically send an email with an excel file containing submissions for a form rather than an email per submission?
- show-hide based on select option jquery wordpress
- Form is not getting submitted [closed]
- Why doesn’t a form need an ‘action’ with a plugin that uses the post data?
- $POST variable is empty in receiving php add-on function but can be seen by jscript function
- Include plugin form in the home page
- Adding an onchange event to a custom dropdown menu in WordPress
- Saving custom form fields
- Linking Plugin Files to WP
- Contact Form 7: custom validation [closed]
- Adding a Filter to Sidbar Login Plugin to Change Login Button Lable
- Undefined variable _POST
- How to develop an extension for a simple form post and post back? [closed]
- How put a file when the email is sent to user contact form 7
- Is it possible to set different payment gateway on each Gravity Forms form? [closed]
- Contact form 7 – How to send mail to two different E-mail Address [closed]
- How can I add a zip code service availability checker in WordPress without Woocommerce? [closed]
- How to make a drop-down list so you can press and change display like on this website by using wordpress or CSS
- How can I create a drawable image for a contact form
- Is there a WordPress plugin or solution that allows to set up forms with a total control over markup
- How to verify/test that a custom built wordpress theme is as secure as possible?