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
SESSION SILVERLIGHT 5 3D : SLIDES ET DEMOSSESSION SILVERLIGHT 5 3D : SLIDES ET DEMOS par Groc
Durant les techdays, j'ai eu le plaisir d'animer une session sur Silverlight 5 et la 3D avec Simon Ferquel. Comme promis, voici nos slides et mes démos (celles avec le viper BSG) ici et là. Pour mémoire, les démos utilisent toutes le viper BSG...
Cliquez pour lire la suite de l'article par Groc [TECHDAYS 2012] SESSION WEBMATRIX 2 : LE COUTEAU SUISSE GRATUIT POUR VOS DéVELOPPEMENTS WEB - SLIDES[TECHDAYS 2012] SESSION WEBMATRIX 2 : LE COUTEAU SUISSE GRATUIT POUR VOS DéVELOPPEMENTS WEB - SLIDES par gpommier
Suite à la session que j'ai présenté sur WebMatrix 2, vous pouvez trouver les slides ici, ainsi que les démos en packages nuget : démos1 et démos2 J'en profite pour remercier chaleureusement tous ceux qui sont venus très nombreux à cette sess...
Cliquez pour lire la suite de l'article par gpommier [SHAREPOINT] LES SESSIONS TECHDAYS 2012.[SHAREPOINT] LES SESSIONS TECHDAYS 2012. par Patrick Guimonet
Voici donc pour ceux qui n'ont pas pu venir, ou ceux qui n'ont pas pu toutes les suivre la liste des sessions SharePoint aux TechDays 2012, que je mettrais à jour dès que les liens des vidéo seront disponibles. Ou ici : http...
Cliquez pour lire la suite de l'article par Patrick Guimonet TECHDAYS PARIS 2012 : SESSION PLEINIèRE JOUR 3TECHDAYS PARIS 2012 : SESSION PLEINIèRE JOUR 3 par ROMELARD Fabrice
Speaker: Bernard Ourghanlian Cette session est comme chaque jour transmise en live par BrainSonic, et j'ai donc suivi cette troisième pleinière par ce moyen sur mon iPad . Elle est dédiée comme chaque année à la mise en perspective de l'é...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice MISHRA READER : UN LECTEUR RSS TRèS ZUNE STYLE EN OPEN SOURCE !MISHRA READER : UN LECTEUR RSS TRèS ZUNE STYLE EN OPEN SOURCE ! par Vko
Hier durant une session dédiée aux Techdays 2012, j'ai eu le plaisir d'annoncer la sortie de la Béta 2 de Mishra Reader. C'est quoi ? Pour les utilisateurs, c'est une vraie expérience de lecture de flux RSS sur Windows. Rien à voir avec les produit...
Cliquez pour lire la suite de l'article par Vko
Logiciels
Tribler (2012)TRIBLER (2012)Tribler est un client pair à pair (P2P/Peer-to-Peer) open source avec la capacité de regarder des... Cliquez pour télécharger Tribler OneSwarm (2012)ONESWARM (2012)Le peer-to-peer qui protège votre vie privée, c'est OneSwarm.
Ce logiciel de peer-to-peer crypté... Cliquez pour télécharger OneSwarm PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA TV DEVIENS HELLLOOO FLASH
LA TV SUR VOTRE ORDINATEUR.
Toute une plateforme Multi... Cliquez pour télécharger PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO Academy System (17.2.1.0)ACADEMY SYSTEM (17.2.1.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System Easy-Planning (1.0.0.1)EASY-PLANNING (1.0.0.1)Basé sur les mêmes principes que MyPlanning, Easy-Planning permet de créer des plannings sous la ... Cliquez pour télécharger Easy-Planning
|