Accueil > > > ENVOI D'UNE LISTE À L'AUTRE + POSSIBLITÉ DE CLASSER UNE LISTE
ENVOI D'UNE LISTE À L'AUTRE + POSSIBLITÉ DE CLASSER UNE LISTE
Information sur la source
Description
Aprés avoir chercher un code entier de ce type de fonctionnalité, je n'ai trouvé que des fragments de code en javascript que j'ai compilé en une page. Ce code permet de transférer d'une liste à l'autre un ou plusieurs éléments, de tout tranférer et d'ordonner dans la liste de droite. Copier coller ce code dans un notepad et sauvegardez ce fichier en page.htm
Source
- <html>
- <head>
- <SCRIPT LANGUAGE="JavaScript">
- function Deplacer(l1,l2)
- {
- for (i=0; i < l1.options.length ; i++)
- {
- if (l1.options(i).selected && l1.options(i)!= "" )
- {
- // alert ("toto");
- // alert(l1.options(i).text);
- // alert(l1.options(i).value);
- o=new Option(l1.options(i).text,l1.options(i).value);
- l2.options[l2.options.length]=o;
- l1.options[i]=null;
- i = i -1 ;
- }
- else
- {
- // alert("Aucun élément sélectionné");
- }
- }
- }
-
- function DeplacerTout(l1,l2)
- {
- for (i=0; i < l1.options.length ; i++)
- {
-
- // alert ("toto");
- // alert(l1.options(i).text);
- // alert(l1.options(i).value);
- o=new Option(l1.options(i).text,l1.options(i).value);
- l2.options[l2.options.length]=o;
- l1.options[i]=null;
- i = i -1 ;
- }
- }
-
- function menuswitch(menu, way)
- {
- // Init
- var menumax = menu.length -2;
- var menusel = menu.selectedIndex;
-
- // Debordement
- if ((menusel < 0) || (menusel < 1 && way == -1) || (menusel > menumax && way == 1)) { return false; }
-
- // Permutation
- tmpopt = new Option( menu.options[menusel+way].text, menu.options[menusel+way].value );
-
- menu.options[menusel+way].text = menu.options[menusel].text;
- menu.options[menusel+way].value = menu.options[menusel].value;
- menu.options[menusel+way].selected = true;
-
- menu.options[menusel].text = tmpopt.text;
- menu.options[menusel].value = tmpopt.value;
- menu.options[menusel].selected = false;
- return true;
- }
-
- function menusubmit(menu1,menu2)
- {
- var menulen1 = menu1.length;
- for (i=0; i < menulen1; i++)
- {
- menu1.options[i].selected = true;
- }
- var menulen2 = menu2.length;
- for (j=0; j < menulen2; j++)
- {
- menu2.options[j].selected = true;
- }
- }
- //-->
- </SCRIPT>
- </head>
- <body>
- <FORM name="formulaire" action="page.htm" method"get" onSubmit="javascript:menusubmit(formulaire.listselect,formulaire.listunselect)">
- <table border="0" cellpadding="0" cellspacing="1" width="400" height="150" bgcolor="#808080" >
- <tr>
- <td height="120" width="200">
- <select name="listunselect" multiple width="200" size="10" OnDblClick="javascript:Deplacer(this.form.listunselect,this.form.listselect)" style="width:180px;font:normal Trebuchet MS;font-size: 9px;">
- <option value="1">Element 1</option>
- <option value="2">Element 2</option>
- <option value="3">Element 3</option>
- <option value="4">Element 4</option>
- <option value="5">Element 5</option>
- <option value="6">Element 6</option>
- </select>
- </td>
- <td height="120" width="50" align="center">
- <input value=" > " type="button" OnClick="javascript:Deplacer(this.form.listunselect,this.form.listselect)"><br>
- <input value=" < " type="button" OnClick="javascript:Deplacer(this.form.listselect,this.form.listunselect)"><br>
- <input value=">>" type="button" OnClick="javascript:DeplacerTout(this.form.listunselect,this.form.listselect)"><br>
- <input value="<<" type="button" OnClick="javascript:DeplacerTout(this.form.listselect,this.form.listunselect)">
- </td>
- <td height="120" width="200">
- <select name="listselect" multiple size="10" width="200" OnDblClick="javascript:Deplacer(this.form.listselect,this.form.listunselect)" style="width:180px;font:normal Trebuchet MS;font-size: 9px;">
- <OPTION value="10">----------------------</OPTION>
- </select>
-
- </td>
- <td height="120" width="50" align="center">
- <input value=" /\ " type="button" onClick="javascript:menuswitch(this.form.listselect, -1)"><br>
- <input value=" \/ " type="button" onClick="javascript:menuswitch(this.form.listselect, 1)">
- </td>
- </tr>
- <tr>
- <td height="30" width="400" colspan= 4 align="center"><input name="bSave" type="submit" value="Valider" style="width:180px;font:normal Trebuchet MS;font-size: 9px;"></td>
- </tr>
- </table>
- <SCRIPT language="javascript">
- // création d'une ligne pour initialiser la largeur puis suppression par ce javascript
- document.formulaire.listselect.options.length=0;
- </SCRIPT>
- </form>
-
- </body>
-
- </html>
<html>
<head>
<SCRIPT LANGUAGE="JavaScript">
function Deplacer(l1,l2)
{
for (i=0; i < l1.options.length ; i++)
{
if (l1.options(i).selected && l1.options(i)!= "" )
{
// alert ("toto");
// alert(l1.options(i).text);
// alert(l1.options(i).value);
o=new Option(l1.options(i).text,l1.options(i).value);
l2.options[l2.options.length]=o;
l1.options[i]=null;
i = i -1 ;
}
else
{
// alert("Aucun élément sélectionné");
}
}
}
function DeplacerTout(l1,l2)
{
for (i=0; i < l1.options.length ; i++)
{
// alert ("toto");
// alert(l1.options(i).text);
// alert(l1.options(i).value);
o=new Option(l1.options(i).text,l1.options(i).value);
l2.options[l2.options.length]=o;
l1.options[i]=null;
i = i -1 ;
}
}
function menuswitch(menu, way)
{
// Init
var menumax = menu.length -2;
var menusel = menu.selectedIndex;
// Debordement
if ((menusel < 0) || (menusel < 1 && way == -1) || (menusel > menumax && way == 1)) { return false; }
// Permutation
tmpopt = new Option( menu.options[menusel+way].text, menu.options[menusel+way].value );
menu.options[menusel+way].text = menu.options[menusel].text;
menu.options[menusel+way].value = menu.options[menusel].value;
menu.options[menusel+way].selected = true;
menu.options[menusel].text = tmpopt.text;
menu.options[menusel].value = tmpopt.value;
menu.options[menusel].selected = false;
return true;
}
function menusubmit(menu1,menu2)
{
var menulen1 = menu1.length;
for (i=0; i < menulen1; i++)
{
menu1.options[i].selected = true;
}
var menulen2 = menu2.length;
for (j=0; j < menulen2; j++)
{
menu2.options[j].selected = true;
}
}
//-->
</SCRIPT>
</head>
<body>
<FORM name="formulaire" action="page.htm" method"get" onSubmit="javascript:menusubmit(formulaire.listselect,formulaire.listunselect)">
<table border="0" cellpadding="0" cellspacing="1" width="400" height="150" bgcolor="#808080" >
<tr>
<td height="120" width="200">
<select name="listunselect" multiple width="200" size="10" OnDblClick="javascript:Deplacer(this.form.listunselect,this.form.listselect)" style="width:180px;font:normal Trebuchet MS;font-size: 9px;">
<option value="1">Element 1</option>
<option value="2">Element 2</option>
<option value="3">Element 3</option>
<option value="4">Element 4</option>
<option value="5">Element 5</option>
<option value="6">Element 6</option>
</select>
</td>
<td height="120" width="50" align="center">
<input value=" > " type="button" OnClick="javascript:Deplacer(this.form.listunselect,this.form.listselect)"><br>
<input value=" < " type="button" OnClick="javascript:Deplacer(this.form.listselect,this.form.listunselect)"><br>
<input value=">>" type="button" OnClick="javascript:DeplacerTout(this.form.listunselect,this.form.listselect)"><br>
<input value="<<" type="button" OnClick="javascript:DeplacerTout(this.form.listselect,this.form.listunselect)">
</td>
<td height="120" width="200">
<select name="listselect" multiple size="10" width="200" OnDblClick="javascript:Deplacer(this.form.listselect,this.form.listunselect)" style="width:180px;font:normal Trebuchet MS;font-size: 9px;">
<OPTION value="10">----------------------</OPTION>
</select>
</td>
<td height="120" width="50" align="center">
<input value=" /\ " type="button" onClick="javascript:menuswitch(this.form.listselect, -1)"><br>
<input value=" \/ " type="button" onClick="javascript:menuswitch(this.form.listselect, 1)">
</td>
</tr>
<tr>
<td height="30" width="400" colspan= 4 align="center"><input name="bSave" type="submit" value="Valider" style="width:180px;font:normal Trebuchet MS;font-size: 9px;"></td>
</tr>
</table>
<SCRIPT language="javascript">
// création d'une ligne pour initialiser la largeur puis suppression par ce javascript
document.formulaire.listselect.options.length=0;
</SCRIPT>
</form>
</body>
</html>
Conclusion
Merci au multiple sources trouvés sur internet.
Sources de la même categorie
Commentaires et avis
|
Derniers Blogs
TECHDAYS PARIS 2010 : SHAREPOINT 2010 POUR LES DéVELOPPEURSTECHDAYS PARIS 2010 : SHAREPOINT 2010 POUR LES DéVELOPPEURS par ROMELARD Fabrice
Animé par: Laurent Cotton Le développement dans SharePoint 2010 passe par plusieurs axes qui seront évoqués dans cette session, mais plus particulièrement les développements simples lié au besoin Business Business Connectivity Services Ce BCS es...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice TECHDAYS PARIS 2010 : PLEINIèRE DERNIER JOURTECHDAYS PARIS 2010 : PLEINIèRE DERNIER JOUR par ROMELARD Fabrice
Cette session est la dernière pleinière de ces 3 jours de TechDays Paris 2010. Généralement, cette troisième journée est plus axée sur l'avenir vu par Microsoft. Après un retour sur l'avenir vu par la Science Fiction ou par ...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice UNE JOLIE-HORLOGE ET PAS QU'UN PEU !UNE JOLIE-HORLOGE ET PAS QU'UN PEU ! par neodante
Pour les possesseurs d'iPhone, ça y est Bijin Tokei - qui se traduit littéralement en Français par " Jolie Horloge " - est arrivé et GRATUITEMENT s'il vous plaît ! Après la version Tokyo, Hokkaido, night club, racing, Gal, "pour les mademoiselles'", . voi...
Cliquez pour lire la suite de l'article par neodante TECHDAYS PARIS 2010 : CONNECTEZ VOS DONNéES à SHAREPOINT 2010 AVEC LES BUSINESS CONNECTIVITY SERVICESTECHDAYS PARIS 2010 : CONNECTEZ VOS DONNéES à SHAREPOINT 2010 AVEC LES BUSINESS CONNECTIVITY SERVICES par ROMELARD Fabrice
Animé par: Gaetan Bouveret et Julien Chomarat Business Connectivity Services (BCS) est dans SharePoint 2010 la version 2 de Business Data Catalog (BDC dans SharePoint 2007). Il s'agit de la solution permettant de visualiser des données provenan...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice [DIVERS] SUIVRE VOS SéRIES PRéFéRéS SUR LA TOILE[DIVERS] SUIVRE VOS SéRIES PRéFéRéS SUR LA TOILE par orion
Comme de nombreux geek, je suis un grand amateur de série TV et je rate régulièrement des épisodes de mes séries préférés. Une solution s'offre à vous avec ce merveilleux site : Tv Gorge - www.tvgorge.com Moteur de recherche à l'appui, vous pouvez ...
Cliquez pour lire la suite de l'article par orion
Logiciels
DB-MAIN (9.1.0)DB-MAIN (9.1.0)DB-MAIN is a data-modeling and data-architecture tool. It is designed to help developers and anal... Cliquez pour télécharger DB-MAIN Xilisoft DPG Convertisseur (5.1.37.0120)XILISOFT DPG CONVERTISSEUR (5.1.37.0120)Xilisoft DPG Convertisseur offre aux fans de Nintendo DS une bonne solution leur permettant de dé... Cliquez pour télécharger Xilisoft DPG Convertisseur GraphicsGale (2.01.01)GRAPHICSGALE (2.01.01)GraphicsGale est un logiciel de PixelArt avec de nombreuse fonctionnalités permettant de réalisé ... Cliquez pour télécharger GraphicsGale Architecte 3D (Platinum 2010)ARCHITECTE 3D (PLATINUM 2010)Architecte 3D Platinium vous permet de concevoir facilement les plans votre future maison, de l'é... Cliquez pour télécharger Architecte 3D TeamViewer 5 (TeamViewer 5)TEAMVIEWER 5 (TEAMVIEWER 5)Dépanner un ami,expliquer une manipulation devient un jeu d'enfant.
Prise en main d'un autre ord... Cliquez pour télécharger TeamViewer 5
|