用于添加的单选按钮值

时间:2010-12-27 09:43:43

标签: php mysql html css ajax

有人可以说这段代码是对还是错?

If(isset($_POST) && ($_POST[‘GET_PAYMENT’] == ‘1’))
{
    $totalAmount = $_POST[‘GET_PAYMENT’]; //Total amount
    $checkbox_id = $_POST[‘VALUE’]; // The radio button value 

    /* Here get the amount values (3,5.5 or 10) from 

    Database based on the $checkbox_id and store it in

    $amount variable*/


    $total_amount = $amount + $totalAmount;


    Echo $total_amount;

}

这是我的单选按钮,当我点击任何一个按钮时,它会具有单独的值,它将添加之前的值

的javascript

Javascript功能

Function getPaymentVal()
{

Var checkboxVal = ‘’;

checkboxVal = $("input[@name=’rmr’]:checked").val();

$.ajax({
   type: "POST",
   url: "ajax.php",
   data: "GET_PAYMENT=1&VALUE=”+ checkboxVal,
   success: function(total_amount)
   {
    //Assigning the final value to the hidden value here
    $(‘#totalamount’).val(total_amount);  

    //Here changing the display of total amount
    $(‘#repair_total_amount’).html(“Total <span class="repair-finalamount-txt">&pound;&nbsp;”+ total_amount+”</span>”);

   }
 });

}

2 个答案:

答案 0 :(得分:0)

看看这段代码,我认为这是可能的,因为"'字符从另一个不同的字符编码源粘贴得很差。您应该再次键入它以查看错误是否发生。

答案 1 :(得分:0)

看起来您从其他来源复制粘贴此代码并且引号混乱。请改用

$.ajax({
   type: "POST",
   url: "ajax.php",
   data: "GET_PAYMENT=1&VALUE="+ checkboxVal,
   success: function(total_amount)
   {
    //Assigning the final value to the hidden value here
    $('#totalamount').val(total_amount);  

    //Here changing the display of total amount
    $('#repair_total_amount').html("Total <span class='repair-finalamount-txt'>&pound;&nbsp;"+ total_amount+"</span>");

   }
 });