html - Php Post Action -


i want post action according select entries. however, code not work. how can do? thank you.

 <form action=<?php echo $filename; ?> method="post"> <br/>     <input type="submit" name="select" value="a" onclick="selecta()" />     <br/>     <input type="submit" name="select" value="b" onclick="selectb()" />     <br/>     <input type="submit" name="select" value="c" onclick="selectc()" />     </form>     <?php         function selecta(){             $filename = "a.php";         }         function selectb(){             $filename = "b.php";         }         function selectc(){             $filename = "c.php";         }         ?> 

you cannot use php dynamically change html. use javascript:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script> <form action="#" method="post" id="myform"> <br/><input type="submit" name="select" value="a" onclick="selecta()"/> <br/><input type="submit" name="select" value="b" onclick="selectb()"/> <br/><input type="submit" name="select" value="c" onclick="selectc()"/> </form> <script> var action = 'a.php'; $(function(){     $('#myform').submit(function(){         $(this).attr('action', action);     }); }); function selecta() {     action = 'a.php'; } function selectb() {     action = 'b.php'; } function selectc() {     action = 'c.php'; } </script> 

Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -