Is this possible? Say someone selected a select option, is there a way to disable the previous (if available) and next (if available) option to the their selected one? Ofc it'll need to use a 'onChange' trigger, but I'm not sure how to do the function part. Any ideas?
So you want a JS function that disables other option tags when selected? Well there are a couple ways you can do that, but I'll out line the idea that came to my head; <!-- HTML SIDE --> <select id="selectBox1" onchange="onSelectChange(this.id,this.value);" > <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> </select> HTML: // JS SIDE // function onSelectChange(targetElement, newValue){ if(newValue = "3"){ runDisableOption(targetElement, 0); runDisableOption(targetElement, 3); } if(newValue = "1"){ runEnableOption(targetElement, 0); runEnableOption(targetElement, 3); } } function runDisableOption(targetSelect, targetNode){ var optionNodeArray = document.getElementById(targetSelect).childNodes; optionNodeArray[targetNode].disabled = true; } function runEnableOption(targetSelect, targetNode){ var optionNodeArray = document.getElementById(targetSelect).childNodes; optionNodeArray[targetNode].disabled = false; } Code (markup): Or something along those lines, I haven't tested the code- so it's just theory. . .
Thanks.... I forgot to say its a multi-select box, will this theory still work? I've attached a screenshot to show that some options are disabled already (by default (by PHP)) so I do not want those disabled options to be enabled again - if you get me.