开发者

how to display the amount values in radio button

hi am developing my project. how do i call the ajax function for onclick button.

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;

}


$.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>”);

   }
 });

}

im confusing with this: data: "GET_PAYMENT=1&VALUE=”+ checkboxVal, which action i have to give.this is for when i clicks that radio button it will be add awith addcart.

can any one


I think you should use:

$.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>”);

   }
 });

EDIT:

Ok, wait. I think what's really going wrong here is that you're adding the value of GET_PAYMENT, which is always 1, to the $total_amount. Try: $total_amount = $amount + $checkbox_id;, or better yet:

$selected_amount = (int) $_POST['VALUE'];
$total_amount = $amount + $selected_amount;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜