This radio button is used on a shopping cart as many times as needed, and just auto changes the name and id:
Code:
<input type='radio' id='{$key1}_{$j}_{$give_itemline_id}' $selected onclick='switchmethod(\"$key\", \"$key1\")' value='$quote' name='shipping_method_{$give_itemline_id}'>
So the 0 at the end of the id and name would increase for each time it's displayed - this is an example of what would be in the actual page for the first time it prints:
Code:
<tr><td class='shipping_header' colspan='4'>Flat Rate - Choose a Shipping Rate</td></tr><tr><td colspan='2'><label for='flatrate_0'>Ground</label></td><td><label for='flatrate_0'><span class='pricedisplay'>$  10.00</span></label></td><td style='text-align:center;'><input type='radio' id='flatrate_0_0'  onclick='switchmethod("Ground", "flatrate", "0")' value='10' name='shipping_method_0'><br /></td></tr><tr><td colspan='2'><label for='flatrate_1'>2nd Day Air</label></td><td><label for='flatrate_1'><span class='pricedisplay'>$  25.00</span></label></td><td style='text-align:center;'><input type='radio' id='flatrate_1_0' checked='checked' onclick='switchmethod("2nd Day Air", "flatrate", "0")' value='25' name='shipping_method_0'><br /></td></tr><tr><td colspan='2'><label for='flatrate_2'>Next Day Air</label></td><td><label for='flatrate_2'><span class='pricedisplay'>$  35.00</span></label></td><td style='text-align:center;'><input type='radio' id='flatrate_2_0'  onclick='switchmethod("Next Day Air", "flatrate", "0")' value='35' name='shipping_method_0'><br /></td></tr><tr style='border-bottom: 1px solid #666;'><td colspan='4'>Next Day Air - flatrate</td></tr><tr class='product_row'>
The javascript being called is this:
Code:
function switchmethod(key,key1){
	total=document.getElementById("shopping_cart_total_price").value;
	ajax.post("index.php",usps_method_switch,"ajax=true&uspsswitch=true&key1="+key1+"&key="+key+"&total="+total);
}

var usps_method_switch=function (results){
	shipping = results.split('---');
	shipping1 = shipping[1];
	jQuery("#checkout_total").html(shipping[0]);
	
	jQuery('.total > .pricedisplay').remove();
	jQuery('.total > .totalhead').after(shipping[0]);
	jQuery('.postage > .pricedisplay').remove();
	jQuery('.postage > .postagehead').after(shipping1);
}

Where I've had a problem, the radio buttons show on the page and work correctly, but I can't get the javascript to correctly add the totals. Originally, there was one set of radio buttons (shipping: ground, 2nd day, and overnight) each with a different price. This was to just add the shipping to the total order for the whole order.

Now I have it so that it needs to add a shipping amount per item to the total. so for example: product 1 = $10, shipping chose at $10, product 2 = $5, shipping chose at $20. How would I get that javascript code to add each shipping to the products total? The total is being calculated. And what I can tell from the javascript above, it's directly grabbing that precalculated total before attempting to add the shipping as the shipping options are chosen.

Any help on this would be so appreciated. I am not very familiar with javascript and need to try to get this working. I wasn't expecting that little chunk of javascript code to be called in a php based ecom system.

Thanks,
Dzynit