select déselectioner tout
Bonjour
J 'ai un souci de fonction javascript que je n arrive pas a faire. J ai 2 listbox et je voudrais que quand l'utilisateur a déjà selectionné des elements dans ces listes, qu'il puisse grâce à un bouton, enlever toutes ces sélections.
j ai donc créer ce bouton sur lequel j ai affecté une fonction.
Mais voila j ai testé toutes les méthodes possibles et imaginables que j ai trouvé sur les forums et il n y a rien qui marche :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
function deselect(){
var listBox = document.getElementById('mod_perso');
var listOk = listBox.selectedIndex > -1;
var listBox2 = document.getElementById('mod_commun');
var listOk2 = listBox2.selectedIndex > -1;
var i;
var j;
/*listBox2.SelectedItems.Clear();
listBox.SelectedItems.Clear();
---------------
/*if ((listOk) && (listOk2)) {
listBox.selected = false;
listBox2.selected = false;
}
------------
for i=0 to listBox.SelectedItems
listBox.selected(i) = false;
next i;
for j=0 to listBox2.SelectedItems
listBox2.selected(j) = false;
next j;
-----------
/*var nb = listBox.options.lenght;
for (var i=0; i < nb; i++){
listBox.options.remove(i);
}
var nb = listBox2.options.lenght;
for (var i=0; i < nb; i++){
listBox2.options.remove(i);
}
---------
/*{while (listBox.options[0]) {
listBox.removeChild(listBox.options[0];}
}*/
} |
quelqu'un aurait il une brillante idée?? merci!!