du12197 2013-05-03 09:40
浏览 132
已采纳

使用2个按钮从一个表单发送POST数据

How can I send the POST data from my form to two different pages depending on which post button is clicked?

My "Export" button sends the POST data to 'export.php', but the "Graphique" button must send the POST data to the 'graphique.php' page.

Here is my 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 I achieve this?

  • 写回答

4条回答 默认 最新

  • douli2063 2013-05-03 09:47
    关注

    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/

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 Revit2020下载问题
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 单片机无法进入HAL_TIM_PWM_PulseFinishedCallback回调函数