"how to write javascript code inside php" Code Answer

2

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>
        ";
     }
  ?>
By dattatray026-2d28e1066aec on August 22 2022

Answers related to “how to write javascript code inside php”

Only authorized users can answer the search term. Please sign in first, or register a free account.