0

hi i have the confusion with my jquery. i have d 4 button to update the value.

let me explain it clearly

this four buttons are select method for an amount. my project is based upon the labtop and iphones. by the shopping cart customer choose the product and then they have to select the button(any 4 in those buttons)

if customer cart amount is 50£ in the sense then they need to choose the radio button if customer select 2 button in the sense the 2nd button amount must add with shopping cart and then displayed like a 55£

if i click the button there is no change when mouse arrow is on the button i could see the error page in below. what action i need to put for the changes i mean the action for the radio button.

<form method="post" form name="make_payment_frm" 
     action="module/make-payment-module.php" 
     onsubmit="return show_make_payment_validation();" >
<input type="radio" name="rmr"  id="payment1" value="30"  
onclick="updatepayment(this.value)" />
<input type="radio" name="rmr" id="payment2" value="39" 
   onclick="updatepayment(this.value)" />
<input type="radio" name="rmr"  id="payment3" value="42" 
   onclick="updatepayment(this.value)" />
<input type="radio" name="rmr" id="payment4" value="45" 
   onclick="updatepayment(this.value)" />
<input type="hidden" name="totalamount" id="totalamount" 
   value="<?php echo get_total_amount(); ?>" />

$(document).ready(function(){ 
      $("input[name='rmr']").click(function() {
       updatePayment($(this).val());
       if (!!$(this).attr("checked") == true) {
         $("#finalamount").html(
          parseInt($("#totalamount").val(), 10) * parseInt($(this).val(), 10));
     }
 });
}

var totalAmount = 50.0; //Set from the database 
function updateAmount(var additionalCost) 
{ 
    document.getElementById("finalamount").innerHTML = totalAmount 
                    + additionalCost;
} 
document.getElementById('payment1').onclick = function(){ 
updateAmount('30') 
}; 
document.getElementById('payment2').onclick = function(){ 
updateAmount('39') 
}; 
document.getElementById('payment3').onclick = function(){ 
updateAmount('42') 
}; 
 document.getElementById('payment4').onclick = function(){ 
updateAmount('45') 
};    

guys can any one tell me the good idea for the radio button works properly. that amount must add with that payment cart and then display.is there any thing wrong in my code. plz help me.

thanks and regards magna ``

2
  • say it in clear. did u want to add value of clicked radio button inside hidden element Commented Jan 5, 2011 at 6:25
  • @mohan ya i mentioned my hidden maount value here,value is 50.that should be change dynamically no need for store the DB Commented Jan 5, 2011 at 6:48

1 Answer 1

1
function updateAmount(var additionalCost)

remove the var there.

Sign up to request clarification or add additional context in comments.

1 Comment

I'm not able to say what's all going wrong if I don't see everything, and I don't see the function updatePayment() anywhere. My answer above is related to an general syntax error, this has to be fixed anyway.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.