The situation is that I have nine unique values for PayPal "add to cart" that I'm trying to place into a single HTML input tag, determined by the combination of choices from two sets of radio buttons (three radio buttons in each set).
The HTML could be slightly different, and the only reason it looks how it is now, is because I've been tinkering with various scripts trying to find a working method. The scripting could probably be much simpler, but I'd just like some help with understanding how to make it function (regardless of which radio buttons are changed, or how many times).
<form id="prod_size">
<input type="radio" name="size" value="1">small</input>
<input type="radio" name="size" value="4" checked="checked">medium</input>
<input type="radio" name="size" value="16">large</input>
</form>
<form id="prod_bundle">
<input type="radio" name="prod_bundle" value="single">single</input>
<input type="radio" name="prod_bundle" value="double">double</input>
<input type="radio" name="prod_bundle" value="triple" checked="checked">triple</input>
</form>
<form>
<input id="cart_button_value" value="green">
</form>
I don't see any errors in the browser console. Everything below is frankensteined from multiple code examples on stackoverflow/stackexchange, because I couldn't find a working solution by itself, unfortunately.
$("#prod_size , #prod_bundle").on('change', function() {
if ('#prod_size' == '1'){
if ("#prod_bundle".value == 'single'){
$("#cart_button_value").val = 'red';
}
else if ("#prod_bundle".value == 'double'){
$("#cart_button_value").val = 'green';
}
else if ("#prod_bundle".value == 'triple'){
$("#cart_button_value").val = 'blue';
}
}
else if ('#prod_size' == '4'){
if ("#prod_bundle".value == 'single'){
$("#cart_button_value").val = 'black';
}
else if ("#prod_bundle".value == 'double'){
$("#cart_button_value").val = 'white';
}
else if ("#prod_bundle".value == 'triple'){
$("#cart_button_value").val = 'gray';
}
}
else if ('#prod_size' == '16'){
if ("#prod_bundle".value == 'single'){
$("#cart_button_value").val = 'orange';
}
else if ("#prod_bundle".value == 'double'){
$("#cart_button_value").val = 'purple';
}
else if ("#prod_bundle".value == 'triple'){
$("#cart_button_value").val = 'pink';
}
}
}).trigger('change');
"#prod_bundle".value... I don't think that line works, also you are searching for vals like single or double that you don't have.