简体   繁体   中英

online shopping cart for payment

hi i want to know about the addcart shopping. im doing the payment process named TRER. i have a problem with clicking button.i setup every code is correct eventhough i could not see any change. i mentioned my product in radio button, i have a 5 radio buttons which has different amount like 20$ 40$ 58.99$ 70$ and 100$. this is the value of 5 radio button. if i clicks the 2 nd button that amount should add to shopping cart.

i have the little confusion with this. i want to know the action on radio button.

<input name="rmr"  type="radio" value="20"    onclick="add_payment_value()" />
<input name="rmr"  type="radio" value="40"    onclick="add_payment_value()" />
<input name="rmr"  type="radio" value="58.99" onclick="add_payment_value()" />
<input name="rmr"  type="radio" value="70"    onclick="add_payment_value()" />
<input name="rmr"  type="radio" value="100"   onclick="add_payment_value()" />

i want to know the ajax function. should i use jquery and ajax togather.

could guys any one post some code else idea.

Wishing you a happy NewYear

thanks in advance mariya

HTML:

<input name="rmr" type="radio" value="20" />
<input name="rmr" type="radio" value="40" />
<input name="rmr" type="radio" value="58.99" />
<input name="rmr" type="radio" value="70" />
<input name="rmr" type="radio" value="100" />

JS:

var rbRmr = $('input[name="rmr"]');

$(rbRmr).bind('change', function(ev) {

    var amount = $(this).val();

    $(rbRmr).attr('readonly', 'readonly'); //block until the query ends Ajax

    $.ajax({
      ...
      data: {value: amount},
      complete: function(xhr, sts) {
         $(rbRmr).removeAttr('readonly'); //unblock
      },
      ...
    });


});

You should try jQuery $.ajax function! If you want to add price to shopping cart you could do something like:

HTML:

<input name="rmr"  type="radio" value="20"    />
<input name="rmr"  type="radio" value="40"    />
<input name="rmr"  type="radio" value="58.99" />
<input name="rmr"  type="radio" value="70"    />
<input name="rmr"  type="radio" value="100"   />

jQuery:

$(document).ready(function(){

    $("input[type='radio']").click(function(){

        var price = $(this).val();

        add_payment_value(price);

    });

});

function add_payment_value(price){

   // here you can use $.ajax function to add your 'price value' to your cart

   $.ajax({

      type: "POST",

  url: "add_payment_price.php", // file where you can add price to your database

  data: "",

  success: function(){} // return something on success

  });

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM