php - Sending POST data from one form with 2 buttons -
how can send post data form 2 different pages depending on post button clicked?
my "export" button sends post data 'export.php', "graphique" button must send post data 'graphique.php' page.
here code:
<form name="tcagregat" class="tcagregat" action="export.php" method="post"> <input type="hidden" name="daco" value="<?php echo $dconso; ?>"></input> <input type="hidden" name="cns" value="<?php echo $cnewcentres; ?>"></input> <input type=submit border="0" class="exp" name="exp" value="export" /> <input type=submit border="0" class="dcb" name="dcb" value="graphique" /> </form>
how can achieve this?
change form action on button click:
$("form").on("click", ":submit", function(e) { $(e.delegatetarget).attr('action', $(this).data('action')); });
html:
<input type=submit data-action="export.php" value="export" /> <input type=submit data-action="graphics.php" value="graphique" />
Comments
Post a Comment