php – 如何$_POST没有点击按钮?

发布时间:2022-04-30 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了php – 如何$_POST没有点击按钮?脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
之前,我有一个带有单选按钮的表单,当然,按下提交时它会在单选按钮中提交值.

但如果我不再需要收音机按钮,我该怎么办呢?当按表格单元格或行时会自动将值提交到下一页而不提交按钮?

<form method="post" action="billing.PHP">
    <table width="900" border="0" align="center" cellpadding="2" cellspacing="0" id='center'>
        <tr>
            <td><input tyPE="radio" name="carrier" <?PHP if (isset($carrier) && $carrier=="LBC") echo "checked";?>  value="LBC"></td>
            <td><img src="../paymentoptions/LBC.jpg" alt="LBC" class="picture"/></td>
            <td><p>The Shipping takes 1-2 days for NCR and 2-3 days for any PRovincial. Payment method only available is through BPI Bank DeposIT<p>
                <div id='price'> Additional ₱250 </div></td>

        </tr>
        <tr>
            <td><input type="radio" name="carrier" <?PHP if (isset($carrier) &amp;& $carrier=="PickUp") echo "checked";?>  value="PickUp"></td>
            <td><img src="../paymentoptions/Pick-up.jpg" alt="Pick-Up" class="picture"/></td>
            <td><p>Personally pick up your merchandise at our office. Free of Charge. Office hours: 10:00 am to 5:00 pm<p>
                <div id='price'> Free!! </div></td>
        </tr>
    </table>
</form>

何在不使用提交按钮或单选按钮的情况下进行提交,因为当我按下行时,它会将值提交到下一页,然后我转到下一页.

谢谢

编辑.

<table width="900" border="0" align="center" cellpadding="2" cellspacing="0" id='centerdown'>
    <tr>
        <td><input type="radio"  name="payment" <?PHP if (isset($payment) && $payment=="BPI") echo "checked";?>  value="BPI"></td>
        <td><img src="../paymentoptions/BPI.jpg"></td>
        <td><p>Pay by BPI bank deposit (we need confirmation of payment through email.)<p></td>
    </tr>

    <tr>
        <td><input type="radio"  name="payment" <?PHP if (isset($payment) && $payment=="PickUp") echo "checked";?>  value="PickUp"></td>
        <td><img src="../paymentoptions/Pick-up.jpg"></td>
        <td><p>Pick up. You have 5 days reservation period. You pay for the merchandise upon pick-up<p></td>
    </tr>
</table>
只需使用行提交即可.考虑这个标记
<form method="post" action="billing.PHP">
    <table width="900" border="0" align="center" cellpadding="2" cellspacing="0" id='center'>
        <tr class="row_submit">
               <!-- ^^ simple class assignment -->
            <td><input type="radio" name="carrier" <?PHP if (isset($carrier) && $carrier=="LBC") echo "checked";?>  value="LBC"></td>
            <td><img src="../paymentoptions/LBC.jpg" alt="LBC" class="picture"/></td>
            <td><p>The Shipping takes 1-2 days for NCR and 2-3 days for any provincial. Payment method only available is through BPI Bank Deposit<p>
                <div id='price'> Additional ₱250 </div></td>

        </tr>
        <tr class="row_submit">
            <td><input type="radio" name="carrier" <?PHP if (isset($carrier) && $carrier=="PickUp") echo "checked";?>  value="PickUp"></td>
            <td><img src="../paymentoptions/Pick-up.jpg" alt="Pick-Up" class="picture"/></td>
            <td><p>Personally pick up your merchandise at our office. Free of Charge. Office hours: 10:00 am to 5:00 pm<p>
                <div id='price'> Free!! </div></td>
        </tr>
    </table>
</form>

然后在你的JS:

<script src="//ajax.GOOGLEapis.COM/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
    $('tr.row_submit').on('click',function(e){
        $('form').submit();
    });
});
</script>

然后在PHP上:

$info_table = array(
    'LBC' => array(
        'price' => 250,'payment' => 'BPI',),'PickUp' => array(
        'price' => 0,'payment' => '',);

if(isset($_POST['carrier'])){
    echo $_POST['carrier'];
    $price = $info_table[$_POST['carrier']]['price'];
    $payment = $info_table[$_POST['carrier']]['payment'];
    echo '<br/>' . $price . '<br/>';
    echo $payment;
}

脚本宝典总结

以上是脚本宝典为你收集整理的php – 如何$_POST没有点击按钮?全部内容,希望文章能够帮你解决php – 如何$_POST没有点击按钮?所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。