I have some problem with my code so PLEASE if you could help me... So I have select box and when I chose first option i need to show some div with some forms, and if I chose second option i need to show another select box.. So that every option from that other select box could show two different forms... So here is my html:
<select id="customer-chose" data-placeholder="Choose">
<option value="0" default selected="">Choose</option>
<option value="current">1</option>
<option value="not" class="next">2</option>
</select>
<select id="user" class="opt">
<option value="0" disabled selected class="not">Chose</option>
<option value="1" class="not">1a</option>
<option value="2" class="not">2a</option>
</select>
<div id="current" class="customer" style="display:none">
<form>
First name: <input type="text" name="firstname"><br>
Last name: <input type="text" name="lastname">
</form>
</div>
And here is my jQuery:
$(document).ready(function() {
$('#user').hide();
$('#customer-chose').change(function(){
$('.customer').hide();
$('#' + $(this).val()).show();
});
$('#customer-chose').change(function() {
if($(this).data('options') == undefined){
$(this).data('options', $('#user option').clone());
}
$('#customer-chose option').click(function(){
$("#user").hide();
});
if($('#customer-chose option:selected')) {
$("#user").show();
} else {
$("#user").hide();
}
var id = $(this).val();
var options = $(this).data('options').filter('[class=' + id + ']');
$("#user").html(options);
});
$('#user').change(function(){
$('.customer').hide();
$('#' + $(this).val()).show();
});
});
And here is fiddle: http://jsfiddle.net/9ARmX/
This code is working but only in Firefox...I need to work in all browsers...