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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
| <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>
<?php
// Paramètres de la Connexion à la base MYSQL
$user="root";
$host="localhost";
$password="";
$database="test";
$connexion = mysql_connect($host,$user,$password) or die ("Connexion au serveur impossible");
mysql_select_db($database,$connexion);
$rq="Select * from script_categorie order by designation;";
$result= mysql_query ($rq) or die ("Select impossible");
?>
<FORM name="formulaire" action="page.php" 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;">
<?php
while($var=mysql_fetch_array($result)){
echo'<OPTION value="Planche"> '.$var["designation"].' </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> |
Partager