2010-12-27 6 views
-1

이 코드가 옳은지, 아니면 잘못 되었 니?추가 할 라디오 버튼 값

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; 

} 

이 내가이 될 것입니다 어느 하나 개의 버튼이 그 이전 값

자바 스크립트

자바 스크립트 기능

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

    } 
}); 

} 
+1

정상적으로'data : {GET_PAYMENT : 1, VALUE : checkboxVal} '을 사용하는 것을 제외하고는 괜찮습니다. 또한 이러한 msword-type 따옴표가 작동 할 수도 있습니다. 당신이 얻는 결과는 무엇입니까? –

+0

가 동의합니다. 꽤 확실한 '과'는 코드를 망칠 것입니다. 대신 '사용해야합니다. – dqhendricks

답변

0

봐와 추가 클릭하면 별도의 값을 가지고 내 라디오 버튼입니다 이 코드에서는 "' 문자가 다른 differe에서 제대로 붙여 넣지 않아 가능하다고 생각합니다. NT 문자 인코딩 소스. 오류가 발생했는지 확인하려면 다시 입력해야합니다.

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>"); 

    } 
});