— Append parent_ to all your top level options’ values like: parent_Course A, parent_Course B
— Also add extra options with the value as “endparent” something like below structure
parent_Course A:
course 1
course 2
course 3
course 4
endparent
parent_Course B:
course 1
course 2
course 3
endparent
Code:
// contact us form - change out optgroup labels
$(function() {
// search for parent_ items
var foundin = $('option:contains("parent_")');
$.each(foundin, function(value) {
var updated = $(this).val().replace("parent_","");
// find all following elements until endparent
$(this).nextUntil('option:contains("endparent")')
.wrapAll('<optgroup label="'+ updated +'"></optgroup');
});
// remove placeholder options
$('option:contains("parent_")').remove();
$('option:contains("endparent")').remove();
});
Related Posts:
- Contact Form 7 plugin refreshing page on submit [closed]
- Download any file after submitting a form [closed]
- Contact Form 7 “non-selectable” options in a drop down [closed]
- Contact form 7 select box different value-text than content-text in option [closed]
- Why “Contact Form 7” doesn’t update PHPmailer library?
- How to get current post ID in Contact Form 7 wpcf7_before_send_mail hook action
- To Disable WordPress Rest API or Not To Disable?
- Custom comment type maybe?
- How to disable autocomplete for inputs in contact form 7? [closed]
- Server side validation for Contact Form 7 [closed]
- get values from contact form 7 wp plugin [closed]
- Add custom variable in Contact Form 7 mail body
- Can’t send mails using contact plugin [closed]
- change captcha design in Fast Secure Contact Form plugin
- Getting value from dymanic text variable into Contact Form 7
- How to escape the tailwindcss responsive syntax when using with contact form 7? [closed]
- Nextcloud integration with wordpress
- Send Contact form 7 data to remote server using .NET api [closed]
- Contact Form 7 Get Image Function [closed]
- how to create progress bar in wordpress contact form 7 or other plugin for set progress bar in cf7 [closed]
- Is there a way to embed a Google Docs form in a page without using plugins?
- Contact Form 7 – Form name blank [closed]
- Not One ‘Contact Form Plugin’ will send email // Work
- how to insert a HTML form into a javascript popup?
- Contact Form 7 – Show image on successful send? [closed]
- How do I add the same contact form to multiple wordpress sites and capture the response in one place or database?
- Send email to multiple addresses on Contact Form 7, but exclude personal details on all but one
- How to modify or create custom contact form 7 select options [closed]
- Hardcode a form in Contact Form 7 [closed]
- Contact Form 7: Load scripts and styles only when there is shortcode? [closed]
- In wordpress how to sent different email separetly when i click on different email ids [closed]
- value not set in contact form 7 plugin of wordpress [closed]
- 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
- Push Contact form 7 variable to front end after submission
- Elementor contact form doesn’t work: “Oops! I cannot send this email!”
- How can I implement radio buttons with icons in Contact form 7?
- Hide button after form submit and save state to localstorage
- Contact Form 7 – Make a selection unavailable after a number of bookings
- WordPress Contact 7 Form – Remove WordPress from the From Sections
- Installation failed, trying to install ANY plugin
- CF7 Custom Recipient – Changing the text
- Multiple CF7 Forms causing multiple recaptcha requests
- 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 send custom mail when a user complete a specific form
- Capture Recaptcha fail event on Contact Form 7
- get/show Last ID
- How to set From filed in contact form 7 Use Mail (2) auto responder
- Form is not getting submitted [closed]
- User content database [closed]
- how to create or rewrite files in wordpress plugin folder
- Contact Form 7: custom validation [closed]
- Retrieving old forms in Contact Form 7 [closed]
- Integrate Mailchimp to a Contact Form 7 contact form [closed]
- How put a file when the email is sent to user contact form 7
- Contact Form 7 Default value from url [closed]
- Can’t edit Contact Us form on front page
- Integrate Razorpay quick payments plugin with contact form7 plugin
- How to do Conact form 7 name field validation? [closed]
- Plugin Beauty Contact Popup Form with while loop
- Contact form 7 – How to send mail to two different E-mail Address [closed]
- prevent contact form 7 from submission on certain condition
- plugin doesn’t retrieve data from database
- Can YOAST SEO fields be removed from custom post type [duplicate]
- Creating Unique Post URLs for A/B Testing… Is this even possible?
- Can’t install local plugin (zip) with wp-cli [closed]
- __autoload in a plugin throws an error in WP – not able to locate translation_entry.class.php
- Stop the form of beign submitted on “Save changes” custom option page
- WordPress with Composer and different plugins for dev/live.
- WordPress Social Login > Post to a users Facebook wall
- How to ‘clone’ a wp plugin to make small changes
- Is there any kind of theme on WordPress to sell my own movies?
- Making sure that a plugin’s scripts and stylesheets are included for dynamicaly loaded content
- JQuery plugin that works with Google 1.10.2 and not with WordPress 1.10.2
- How to use is_single and get_post_type within a plugin?
- What is wordpress way to access a plugin’s classes/models to load custom post type data?
- Change wp-login to custom URL login page
- Historical customisations won’t go away [closed]
- Can I restore a plugin that was accidentally deleted? (on localhost)
- Readme.txt not getting updated
- Get access to WordPress when logged out
- Stop a script on a single page
- How to get database connection details without longing to cpanel in WordPress?
- How to translate wordpress blog to other languages?
- Override plugin images so that they are not removed when the plugin is updated
- Login/password protected “client page”
- Change custom rewrite rule when permalink is updated/changed
- Image paths wrong after migrating with wp-migrate-db-pro media files add-on
- How to load a plugin when doing an Ajax call? [duplicate]
- Define constant for one plugin in mu-plugin
- How to fix vanilla comments extra iframe space
- MultiPostThumbnails and media queries
- Get a submitted value from front end post form for single template
- Reply form used in wordpress.com
- Language switcher with flags – Polylang WP plugin
- PM PRO addon package check user access to a specific post
- wordpress or jquery a dynamic photo gallery
- Can’t save formdata in DB
- Event Made Easy – Block registration to two or more events that have the same category