I'm trying to assign two values to a select option and select one or the other depending on the result of a subsequent radio button.
So for instance, in this example, I used 2 different shirts with two different prices depending on the size of the shirt you pick. I know this code doesn't work, probably because of the "value1" and "value2" but I am just putting it here to illustrate what I am trying to achieve.
http://jsfiddle.net/Shibi/o2hftb6e/3/
Any help would be great. Thanks!
HTML
<select id="shirts">
<option>Choose shirt</option>
<option value1="15" value1="20">Shirt 1</option>
<option value1="20" value1="25">Shirt 2</option>
</select>
<div>
<input type="radio" name="1" value="small" />Small
<input type="radio" name="1" value="medium" />Medium</div>
<div id="priceSummary"></div>
JS
$('#shirts').on('change', function () {
var selectedShirtText = $("#shirts :selected").text();
var selectedShirtValue = $("#shirts :selected").val();
$("#priceSummary").text(selectedShirtText ? ("Price of: " + selectedShirtText + " " + "$" + selectedShirtValue) : "");
});
#in$("priceSummary")selectedShirtTextValuevsselectedShirtTextvalue1is not a valid HTML attribute. Do you mean usingvalue? Your approach to the scenario is also problematic — your design indicates that shirts 1 and 2 are possibly mutually exclusive options.