— 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
- Issue using form in Google app in mobile
- How can I create a drawable image for a contact form
- Missing Contact Form/Form Default Plugin in WordPress
- How to get URL param for pagination in shortcode?
- qTranslate‑X is not translating all shortcodes
- WordPress REST API filter on blank custom ACF
- Ajax Load More stopped working (Plugin with repeater template, shows hidden Button)
- Add_rewrite_rule in HivePress (WordPress plugin/theme)
- How do I call an action hook into wp_ajax hook callback function
- How to change and edit users according to the extension in the URL
- How to add a static image inbetween the product tiles on main shoppage woocommerce?
- Plugin download link
- Issue with customizer and widget page
- Posts in Admin only display 1 Post instead of all Post in admin area
- thumbnail_width not working in wordpress most popular post plugin
- Gravity Forms and Gravity View Permissions
- edit slider plugin capability for custom_role
- WordPress Plugin and other pages not opening
- Meta box not displaying on the plugin page
- Inline AJAX script passing variables to PHP
- Plugin Block at the backend of every page or post
- How can I save the selected page in the dropdown after anyone clicks on Save Changes?
- Warning: Undefined variable $admin
- How can I display an attribute from each post inside foreach($latest_posts1 as $post )
- add_meta_box showing blank screen in my page
- Wrong block appender button showing
- How to get attributes from block.js into php
- Cannot edit Sidebar in any theme in wordpress
- how to update wordpress plugin programmatically using plugin path
- wp_options Table keeps growing
- Check Plugins in Use by Mutli Site Network
- Option value not getting updated until page refresh in WordPress
- How to create an Info Box on WordPress [closed]
- Plugin with Fatal error
- I want to display data last 7 days with date wise in chartjs?
- Make plugin admin page visible to other roles