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" /> 

http://jsfiddle.net/fanq9/


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -