You can’t add logic for changing in that way. You need react on user “front-end” event with js.
Also this construction will work wrong:
document.getElementById(\"form\").innerHTML = \"[contact-form-7 id=\"formId\"]\";
Will be always print [contact-form-7 id=\”formId\”], because js can’t do_shortcode function itself.
If you wanna make it simple(without ajax process) you need:
1) Print all forms with php and style “display: none;”
2) Add onchange event for select
3) On change options “show” needed form
Quick example how print forms:
$formDivs="";
forearch($ids_array as $i=>$id) {
$formDivs .= do_shortcode("<div id=\"form_{$i}\" style="display: none;">[contact-form-7 id=\"{$id}\"]</div>");
}
Related Posts:
- Run shortcode at certain resolution
- Trigger popup in a php if/else statement
- Calling PHP Titles inside Javascript Markup
- using shortcodes inside gravity forms
- How to output values from a loop into a javascript array
- Replacing entire tag with shortcode – JavaScript [duplicate]
- Force ‘permanent’ post cache of shortcode results
- How can i iterate through this shortcode array?
- Set variable in javascript and using in my shortcode
- Is there a better way to output HTML as a shortcode?
- Show Login Errors In WordPress/Elementor (Code “works”, but breaks site)
- WordPress Infinite Scroll without using any plugin
- Create Image Uploader for Widget
- WordPress Ajax always returns a 404 error
- Conditionally loading JavaScript based on the Advanced Custom Fields in the post
- Is there a reason why my wordpress PHP page isn’t loading into my PHP template
- How to resize image on client-side before upload?
- Limit the Excerpt field in WP-Admin in words
- How to return a string that has a variable inside in a shortcode?
- Passing a shortcode attribute to a sub-function
- Audio Player not loading when the content is loaded through Ajax, MediaElement.js no applied
- Customizer Show/Hide Logo and Site Title
- Use different javascript files for each page on website
- Create custom blocks for bootstrap
- Click loads template via ajax
- Sending jsPDF documents to the server
- is_page “range” for if statement?
- How can I generate random numbers inside my shortcodes on each implementation?
- js file in root loading without
- Use menu link or onClick to set a variable
- Different loop output every x posts in custom post type
- Showing a different gallery in a seperate post
- Displaying admin notices inside the block editor from rest_after_insert_{$this->post_type} hook
- WordPress Shortcodes.. printf is outputting a random number… Can’t figure out WHY?
- wordpress visual composer change grid builder post link
- How to pre populate a form field with a link of a current user’s author profile?
- parts of url disappear when using # inside href=”” [closed]
- How do I Import / Upload Files with jQuery AJAX?
- Noscript not working as it should in wordpress site
- Excecuting php function in shortcode
- PHP echo inside javascript
- Returning data instead of echoing/printing
- How to add API security keys into JS of wordpress securely
- HTML escaping data with ajax requests
- do_action(), iFrame Gets Displayed Despite Password Protection [closed]
- Using Shortcode to Grab Archive Listing, Separate by Year
- 2nd page displaying the exact same posts as my first page (minus the very first post)
- List all blogs, but exclude the main site
- How to use wordpress function wp_enqueue_script() in php?
- Get related product based on subcategory selected from category id with ID 142
- wp_nav_menu not working correctly in my underscores theme
- PHP code inside Shortcode
- url_to_postid returns 0
- How do i add slugs to a URL, but still redirecting to the same page
- Action Hook Inside WordPress Plugin Shortcode
- How can I include the user id inside of a shortcode php output?
- PHP Helper Class to create shortcodes
- Link to page with posts of specific type
- implementing a jQuery “click to expand” link in WordPress [closed]
- random reason on refresh
- Change Query Arguments (filter) with jQuery/Ajax or PHP?
- Some problems in custom widget
- Call a function in functions.php from within tags (JS)
- Hook on file upload
- Using Ajax to submit a form, and run a SQL Select query based on user input from the form
- Updating Metadata with Shortcode
- Tracking Visitor LatLng with WordPress using JS, PHP. How to put data which was extract using JS into DB
- WordPress Search Ajax + Isotope + InfiniteScroll
- WordPress User Meta value variable into Google Gauge Chart
- Create shortcode for metabox gallery
- How to call my PHP function with AJAX ? wp_query
- Create a WordPress Contact Form to call a POST AWS API Gateway and send user data
- Admin-ajax.php 404 error
- How to pass values from one function to the other using an array variable
- couldnt show short code atts in category
- separate list of programs in html/javascript coming from php
- Advanced Custom Forms PHP formatting for do_shortcode
- overwrite wordpress gallery with custom gallery shortcode
- Open/closed function [closed]
- What is wrong with this shortcode? to include external php file in WordPress posts
- Target a specific container to style on WordPress storefront theme
- Need to Echo A Url path to show on a wordpress page
- ACF + WP + Slick Slider Repeater Slide Group PHP not Displaying [closed]
- Default Image not showing up in Customizer for WP_Customize_Cropped_Image_Control
- How to create a radio button to alt between settings in wp_options table
- customizer live preview layout picker
- I need help implement a Javascript code into the PHP file
- Formatting Shortcode to Display in Visual Mode
- How to pass parameter that ends up being part of a class name with wordpress shortcode
- Admin bar nodes
- How can I correctly POST to a WordPress page?
- Overwriting a Shortcode
- if is_home(), change class of menu-item-225 of wp_nav_menu
- Load php function with AJAX on modal window
- A next page function with shortcode?
- using a shortcode in a hyperlink
- JSON Object Value Show Undefine
- Display total count of products in orders of a specific order status
- HTTP 500 Error after Creating Shortcode
- How to execute a shortcode within a custom field?