I have drop down select and show hide other fields (within divs) based on option selected in the dropdown list.
This code works fine and show hide based on selection but
I would suggest adding a class for your loaded content which will make them hidden.
HTML
JS
$('#row1_layout_options').change(function() {
$('#layouts>div.selected').removeClass('selected');
$('#row1_col1_' + $(this).val()).addClass('selected');
});
CSS
#layouts>div{
display:none;
}
#layouts>div.selected{
display:block;
}
EDIT : Saving selected
As for saving the selected option you have these non exhaustive list of solution :
localStorage
which is a javascript accessible store that is flushed like cookies. I wouldn't recommend that one I found it very much unreliable.selected
you send a query to a webservice that will save the state somewhere (DB, object instance etc...)http://localhost/mysite?selectedId=2
. This way you can have the information directly within the link. Easier to share the state.