I have a select menu that is used for selecting the quantity of jerseys desired.
<select name="jerseys" class="mobile">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
Based on the quantity selected, I would like to output that same number of a specific div class called "block". For example, if "2" is selected, 2 divs of the same class show like this:
<div class="block">
Jersey #1 Info:
<select name="jersey_one_size">
<option>S</option>
<option>M</option>
<option>Large</option>
</select>
</div>
<div class="block">
Jersey #2 Info:
<select name="jersey_two_size">
<option>S</option>
<option>M</option>
<option>Large</option>
</select>
</div>
Would also like to output the text "Jersey #1 Info" "Jersey #2 Info" dynamically as well as select names "jersey_one_size" "jersey_two_size" etc.
I know I could do it manually this way:
$('select[name=jerseys]').change(function() {
if ($(this).val() == '1') {
// show .block1
}
});
But how dynamically?