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
- ES6 Map in Typescript
- How do I color a hexagonal grid such that it doesn’t have neighbors of the same color?
- JavaScript equivalent to printf/String.Format
- What is the “right” JSON date format?
- jQuery animate backgroundColor
- Node update a specific package
- How to fix RichEmbed Discord.js
- How to convert selected HTML to Json?
- Express error – TypeError: Router.use() requires middleware function but got a Object
- Why does JSHint throw a warning if I am using const?
- Uncaught TypeError: .indexOf is not a function
- Get all non-unique values (i.e.: duplicate/more than one occurrence) in an array
- How to set onClick with JavaScript?
- How can I use webpack with express?
- JavaScript check if variable exists (is defined/initialized)
- Embedding instagram webpage inside an iframe
- Javascript – Replace html using innerHTML
- Syntax error: Illegal return statement in JavaScript
- How to export JavaScript array info to csv (on client side)?
- Should I use encodeURI or encodeURIComponent for encoding URLs?
- How to add code to just before closing body tag
- Customizer JS API: Defining control settings
- Is there a reason why my wordpress PHP page isn’t loading into my PHP template
- Updata Metadata WP Rest API
- POST from jQuery to PHP
- How to add JavaScript file using wp_enqueue_scripts?
- Sending jsPDF documents to the server
- Enqueue js script to footer
- Displaying admin notices inside the block editor from rest_after_insert_{$this->post_type} hook
- Add A Tag To A Post Through JavaScript In Gutenberg UI?
- How to reference TinyMCE body in my script
- wordpress admin plugin menu custom css
- Easiest way to find JS conflicts
- PHP or JS for header image rotator?
- Send foreach $_post method to contact form 7 [closed]