I'm creating a form where certain fields should only show depending on the initial product selected, here's the JS i have:
<script type='text/javascript' src='http://code.jquery.com/jquery-1.6.4.js'></script>
<script type='text/javascript'>
//<![CDATA[
$(window).load(function() {
$("#product").change(function() {
var selected = $("#product option:selected").text();
$('div').hide();
$('#' + selected).show();
});
$(document).ready(function() {
$('div').hide();
});
}); //]]>
</script>
and here is the HTML so far:
<select id="product">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
</select>
<div id="1">Options that are available for Product 1</div>
<div id="2">Options that are available for Product 2</div>
<div id="3">Options that are available for Product 3</div>
<div id="4">Options that are available for Product 4</div>
<div id="5">Options that are available for Product 5</div>
<div id="6">Options that are available for Product 6</div>
<div id="7">Options that are available for Product 7</div>
The problem i'm having is that in the options (1/2/3/4/5/6/7) these need to be product names, but it doesnt work without the numbers in there. So for example 1 should be called Product 1, 2 should be called Product 2, and so forth.
Can you help?
Product 1, Product 2, ...instead of1,2,...