This is the script I am using:
- $('input[type=radio]').change(function() {
// change the page per this logic
switch ($('input[type=radio]:checked').val()) {
case '30ml':
$('.price').text('6.49'); break;
case '100ml':
$('.price').text('12.99'); break;
default:
$('.price').text('6.49');
};
});
If I try to implement your solution, nothing happens - what am I doing wrong?
- $('input[type=radio]').change(function() {
// change the page per this logic
switch ($('input[type=radio]:checked').val()) {
case '30ml':
$(this).parent("form").next("span.price").html("6.49"); break;
case '100ml':
$(this).parent("form").next("span.price").html("12.99"); break;
default:
$(this).parent("form").next("span.price").html("6.49");
};
});
EDIT:
OK, so this now works, but only for the first instance of the form:
- $('input[type=radio]').change(function() {
// change the page per this logic
switch ($('input[type=radio]:checked').val()) {
case '30ml':
$(this).closest("form").find("span.price").html("6.49"); break;
case '100ml':
$(this).closest("form").find("span.price").html("12.99"); break;
default:
$(this).closest("form").find("span.price").html("6.49");
};
});
For any other forms, it changes correctly betwen 6.49 and 12.99 for the others, it just shows 6.49