I have a JS in the HEAD which swaps CSS to show/hide elements by their ID. This works without issue when the event is an ONCLICK applied to elements such as links, or buttons or the like:
Code:
onclick="swapClass('wrap1','divoff','wrap2','divon')"
However, i'm struggling with how to apply the event to a specific option-value in a select-list. I understand this needs to be done by calling the function via ONCHANGE on the SELECT element.
Code:
<select name="list" onchange="swapClass('wrap1','divoff','wrap2','divon')"
This works, in that ANY and ALL options in the select-list will fire the JS.
But how then to restrict the event to a specific OPTION in that list? For example, the 5th element (index #6)
Some things i tied that SEEMED promising but dont work:
Code:
<select name="list" onchange="swapClass('wrap1','divoff','wrap2','divon'[this.selectedIndex+6])"
Code:
<select name="list" onchange="swapClass('wrap1','divoff','wrap2','divon').this.selectedIndex+6"
As with most of my JS struggles, it seems to boil down to a matter of syntax & formatting.