How to link two <select> elements?
-
Hello. I'm not sure about how to do that. It seems simple. I have two elements that have two excluding values, A and B. What I need is that if I select A option in one, B is set in the other, and if I set B, the other is set with A. How can I do that? Regards, Diego F.
-
Hello. I'm not sure about how to do that. It seems simple. I have two elements that have two excluding values, A and B. What I need is that if I select A option in one, B is set in the other, and if I set B, the other is set with A. How can I do that? Regards, Diego F.
-
-
Thank you, but I'm not sure if that is what I need. I find examples from one select loading another select. But I have two select that have the same two options, and any of them can be selected, so the other takes the other value.
Regards, Diego F.
Diego F. wrote:
the other takes the other value.
Meaning it should NOT be the same as the one in the first dropdown? You may need to actually iterate through the options array to achieve the same and unselect in case of violation?
Vasudevan Deepak Kumar Personal Homepage Tech Gossips
-
Hello. I'm not sure about how to do that. It seems simple. I have two elements that have two excluding values, A and B. What I need is that if I select A option in one, B is set in the other, and if I set B, the other is set with A. How can I do that? Regards, Diego F.
Is this what you're after? <!-- function s(a,b){ var sel1 = document.getElementById(a); var sel2 = document.getElementById(b); if (sel1.selectedIndex==0) { sel2.selectedIndex=1; } else { sel2.selectedIndex=0; } } //--> One Two One Two
-
Diego F. wrote:
the other takes the other value.
Meaning it should NOT be the same as the one in the first dropdown? You may need to actually iterate through the options array to achieve the same and unselect in case of violation?
Vasudevan Deepak Kumar Personal Homepage Tech Gossips
What I need is that: select1: options A and B select2: options A and B Select1 is set to A --> Select2 is set to B Select1 is set to B --> Select2 is set to A Select2 is set to A --> Select1 is set to B Select2 is set to B --> Select1 is set to A Maybe the above explanation wasn't clear enough.
Regards, Diego F.
-
Is this what you're after? <!-- function s(a,b){ var sel1 = document.getElementById(a); var sel2 = document.getElementById(b); if (sel1.selectedIndex==0) { sel2.selectedIndex=1; } else { sel2.selectedIndex=0; } } //--> One Two One Two
-
Hello. I'm not sure about how to do that. It seems simple. I have two elements that have two excluding values, A and B. What I need is that if I select A option in one, B is set in the other, and if I set B, the other is set with A. How can I do that? Regards, Diego F.