In my application I have two listboxes, one with "available players" and one with "scaled players", as well as two buttons to move the items between them, > and > .
My problem is this. As soon as I select an item in one of the listbox, and in the click sequence on some item in the OTHER listbox, the item that was first clicked is still selected.
I need a way to do the following. Example: I first click on a name in the left listbox and the > > button to move the item to the right listbox is enabled. But then I realize that this is not what I wanted and I click on a name from the RIGHT listbox this time. Since there is now one selected in it, the button is enabled. However, the first option clicked in the other listbox is still selected, and the > > button is still enabled. I need that when clicking on another listbox, all the items that by chance have been selected in the previous listbox, are deselected.
Below is an image of the problem, with the two move buttons enabled at the same time, due to the problem I described above.
And below is the code that enables and disables the buttons:
function habilitarBotoes(){
var disponiveis = document.getElementById("jogadores_disponiveis");
var escalados = document.getElementById("jogadores_escalados");
var toRight = document.getElementById("toRight");
var toLeft = document.getElementById("toLeft");
var salvar = document.getElementById("salvar");
var data = document.getElementById("data");
if((getOpts(disponiveis).length > 0) && (getOpts(disponiveis).length + escalados.length <= 5)){
toRight.disabled = "";
} else {
toRight.disabled = "disabled";
}
if(getOpts(escalados).length > 0){
toLeft.disabled = "";
} else {
toLeft.disabled = "disabled";
}
if((escalados.options.length == 5) && (CheckDate(data) == true) ){
salvar.disabled = "";
} else {
salvar.disabled = "disabled";
}
}