I am trying to show/hide elements based on the currently selected option. I have a rough idea of how to do this, but am having trouble with my javascript syntax.
Here is the basic logic behind what I am trying to accomplish:
1. All divs specified here will start off hidden
2. If currently selected option = Books || Catalogs || Magazines || Newspapers, then show div#binding
3. If currently selected option = Brochure
then show div#catalog
Here is my humble attempt
[HTML]<select name="publicati ons" onchange="if (this.value == 'Books' || 'Catalogs' || 'Magazines' || 'Newspapers') {
$('binding').sh ow(); }
else {
$('binding').hi de(); }
if (this.value == 'Brochures') {
$('brochure').s how(); }
else {
$('brochure').h ide(); }"[/HTML]
My main problem is I dont understand the proper way to test for multiple values (as you can see in those butchered OR statements)
I also have the issue of the divs being initially visible. perhaps I need to manipulate the dom to change CSS classes or something.
Here is the basic logic behind what I am trying to accomplish:
1. All divs specified here will start off hidden
2. If currently selected option = Books || Catalogs || Magazines || Newspapers, then show div#binding
3. If currently selected option = Brochure
then show div#catalog
Here is my humble attempt
[HTML]<select name="publicati ons" onchange="if (this.value == 'Books' || 'Catalogs' || 'Magazines' || 'Newspapers') {
$('binding').sh ow(); }
else {
$('binding').hi de(); }
if (this.value == 'Brochures') {
$('brochure').s how(); }
else {
$('brochure').h ide(); }"[/HTML]
My main problem is I dont understand the proper way to test for multiple values (as you can see in those butchered OR statements)
I also have the issue of the divs being initially visible. perhaps I need to manipulate the dom to change CSS classes or something.
Comment