[jQuery] click(function(select) help
Hi again,
I have a form with products select menu. I would like to show and hide
product specific options as the user selects them. Now, I can show the
product options but I don't know how to hide them if the user selects
a different product.
My HTML is:
.... snip...
<select id="product-type" name="product-type" class="product-type">
<option value="select" selected="selected">-Select-</option>
<option value="product a" class="producta">Product A</option>
<option value="product b" class="productb">Product B</option>
</select>
<fieldset class="producta options"> ... </fieldset>
<fieldset class="productb options"> ... </fieldset>
.... snip ....
My code at the moment is:
$('#orderform').find('.options').hide();
$('.product-type').find('option.producta').click(function(select) {
$('fieldset.producta').slideDown("slow");
});
$('.product-type').find('option.productb').click(function(select) {
$('fieldset.productb').slideDown("slow");
});
So, if I change the user changes his/her mind between product a to
product b, the options stay visible, and I'm not sure how to hide them
again.
Also, if the user already entered information in the fieldset's
fields, should I reset them when I hide them?
Any advice will be great.
Thanks,
Elle