Just echo the javascript out inside the if function
<form name="testForm" id="testForm" method="POST" > <input type="submit" name="btn" value="submit" autofocus onclick="return true;"/> </form> <?php if(isset($_POST['btn'])){ echo " <script type=\"text/javascript\"> var e = document.getElementById('testForm'); e.action='test.php'; e.submit(); </script> "; } ?>
Related Posts:
- How to pop an alert message box using PHP?
- Reactjs – Form input validation
- Angular: mat-form-field must contain a MatFormFieldControl
- No value accessor for form control
- Send POST data using XMLHttpRequest
- Setting onSubmit in React.js
- jQuery AJAX submit form
- How do I embed PHP code in JavaScript?
- How to use php code in javascript
- How to reset a form using jQuery with .reset() method
- How do I pass variables and data from PHP to JavaScript?
- Execute PHP function with onclick
- JavaScript post request like a form submit
- Mixed Content Page: requested an insecure stylesheet error
- How to create a HTML Cancel button that redirects to a URL
- What does ngf-select do and why is it needed for form validation?
- SyntaxError: Unexpected token C in JSON at position 0 – Ionic 2 Http GET request
- SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
- JavaScript post request like a form submit
- is there something like isset of php in javascript/jQuery?
- How can I get form data with JavaScript/jQuery?
- how to call a onclick function in tag?
- How do I refresh a DIV content?
- Only on Firefox “Loading failed for the script with source”
- How to open a URL using PHP?
- {“error”: “Please use POST request”} – alternative solution to submitting a form
- Keep getting a “Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup” when attempting to google plus login on my web app
- FormData append not working
- JavaScript code to stop form submission
- Ajax success function
- AngularJS POST Fails: Response for preflight has invalid HTTP status code 404
- ngular is automatically adding ‘ng-invalid’ class on ‘required’ fields
- WordPress Bootstrap Handburger Menu Wont Open
- Add custom form to theme
- How to replace a javascript select box onchange event to a form submit action?
- Custom WordPress+PHP+MYSQL+AJAX form, submit event not captured by Javascript, but does POST data to the DB
- How do I embed a Javascript form directly into a page?
- How to load javascript file on homepage in WordPress in order?
- How to pre populate a form field with a link of a current user’s author profile?
- How to insert HTML/JavaScript form into WordPress page? [closed]
- AJAX not Working with php as supposed
- How do you filter the list of states when country is selected? [closed]
- Uncaught ReferenceError: jQuery is not defined – although jQuery is loaded [closed]
- Why does a on Comment edit page submit the page?
- How to add “on change” to a text input in contact form7?
- coding a WordPress AJAX Form using PHP to check if User is Logged Out and Show error
- Submitting a form, using Ajax, to run a SQL Select query based on user input from the form
- Getting a variable inside foreach from PHP to JS after localization
- Add captcha validation to my custom form for Frontend posting
- How to add a onclick attribute to a list of checkboxes?
- Close modal window after form submit [closed]
- Testing a Form’s Zipcode Field with Regular Expressions to Determine WordPress Page Behaviour
- Using Ajax to submit a form, and run a SQL Select query based on user input from the form
- Cascading dropdown select search based on Parent Page & Child Page
- Form will not popup, when clicking on the link to the form
- How to show cities according to the state in Form using Javascript? [closed]
- Can’t Listen to KeyDown in TInyMCE Iframe (jQuery) and Pass it to Parent HTML FORM
- Javascript / PHP – closing the loop
- Error handling for wpdb error – displaying an error message to the user
- Open image gallery on link click
- How to change number field to text field using JS
- How do I convince this button to do something when it is clicked?
- how to show selected options drop down menu values in attributes field in after saving post.php
- CCF7 Field numbuer prefilled after Click event
- Sending GravityForms to custom HTML
- Validate a custom form with js and php
- Custom PHP contact form issue
- Adding Custom Forms
- Unwanted line break before
- Hide reply button after moveForm is called
- How do I let users upload files to a chosen location?
- How to use div -ids in url to jump to specific post…Is trailing slash the culprit?
- Gutenberg add extra attributes to custom format
- Trying to implement Ajax comments in WordPress, getting WP error
- How to test nonce with AJAX – Plugin development
- woocommerce registration form with klaviyo(don’t work with current user)
- Adding JavaScript to a WordPress website
- wp-env mysqlcheck error:1130
- Using wp.data.select get actual tags (not id’s) used in post
- How do I display a user’s previous orders as a select box option on a product?
- Simple Plugin with custom javascript wont work – no console error
- add mediaelement.js plugins into WordPress video player control bar
- How does this WordPress Plugin (Thrive Comments) apply their custom comment sort? [closed]
- Shortcode button dosent work for all posts. Work for first post only
- How can I use a modal window to display the current post in loops featured image?
- event/callback on block update?
- can a buttongroup have a label?
- js file in root loading without
- How do developers add “Smooth Transitions” to their sites?
- Insert “javascript:void(0);” into URL
- class click counter save number
- Exclude JS file from 404 error page
- Custom form action to handle data inside a plugin
- wp.editor.initialize does nothing
- Trigger popup in a php if/else statement
- How to remove p / br elements from gutenbergs editor
- Custom wp.editor.initialize settings ignored
- Why my javascript code not working for the dashboard of wordpress admin?
- Pulling data from custom plugin settings using PHP shortcode and Javascript
- Slider loading issue