bonjour tous le monde
j'ai deux select, et je bascule des valeurs d'un à lautre,
je souhaite récupérer les valeurs du 2eme select pour un traitement ultérieur
voici mon code
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
 
$params	= array
	(
	'sAction' 		=> 'CONT',
	'iType'			=> 26,
	'iCat'			=> 'N',
	'sCountry' 		=> 'fr',
	'sLang'    		=> 'fr',
	'sVhost' 		=> 'www',
	'bIsHot'		=> 0,
	'iPage'			=> 1,
	'iMaxByPage'	=> 100,
	'iAbo'			=> 0,
	'onlyMP'		=> 0,
	'showOwner'		=> 1,
	'idProduct'		=> 0,
	);
 
	$oKernel = new CManager($params, false);
	$aResults = $oKernel->getInfos();
	$oKernel->close();
 
function affSelect1Jeux($aResults){
 
//------récupérer tous les jeux-------------	
 
	var_dump($_POST["list1"]);
	//echo $_POST["list1[0]"]; 
	//echo '<br>';
//-----récupérer les libellés dans un select 	
 
	$sOut  = '<select name="list1" multiple="multiple" size="10" >';
	foreach ($aResults as $k=>$v){
 
		foreach ($v as $c=>$val){
			$i=1;
			$sOut .= '<option value="'.$val['id'].'">'.$val['lib'] .'<br>';
			$i++;
		}
	}
 
	$sOut .= '</select>';
 
	/*if(isset($_POST["_range"])) {
	$sOut = str_replace('value="'.$_POST["_range"].'">', 'value="'.$_POST["_range"].'" SELECTED>', $sOut);
	}*/
	return $sOut;
}
 
function affSelectedJeux()
{
	$sOut  = '<select name="list2" multiple="multiple" size="10" >';
 
 
	$sOut .= '</select>';
 
	/*if(isset($_POST["_range"])) {
	$sOut = str_replace('value="'.$_POST["_range"].'">', 'value="'.$_POST["_range"].'" SELECTED>', $sOut);
	}*/
	return $sOut;
}
 
function affSelectRange()
{
	$sOut  = '<select style="width:120px" name="_range" onchange="document.forms[\'MyForm2\'].submit();" class="SelUrl">';
	$sOut .= '<option value="1">Tout</option>';
	$sOut .= '<option value="2">Default</option>';
	$sOut .= '</select>';
 
	if(isset($_POST["_range"])) {
		$sOut = str_replace('value="'.$_POST["_range"].'">', 'value="'.$_POST["_range"].'" SELECTED>', $sOut);
	}
	return $sOut;
}
 
function affSelectLang($aLang)
{
	switch ($_POST["_range"])
	{
		case 2:
			$sOut .= '<td><select style="width:120px" name="_sel" onchange="document.forms[\'MyForm2\'].submit();" class="SelUrl" style="width:30px">';
			foreach($aLang as $t)
			{
				$sOut .= '<option value="'.$t.'">'.$t.'</option>';
			}
			$sOut .= '</select>';
			$sOut .= '</td>';
			break;
	}
	if(isset($_POST["_range"])) {
		$sOut = str_replace('value="'.$_POST["_sel"].'">', 'value="'.$_POST["_sel"].'" SELECTED>', $sOut);
	}
 
	return $sOut;
}
 
function getpreviews($filename){
 
	$Url= 'http://pics.mediaplazza.com/t_26/games/'.$filename.'/118/'.$filename.'.gif';
}
function affichepreviews(){
 
	tabId();
}
?>
 
 
 
<script language="JavaScript">
function hasOptions(obj){if(obj!=null && obj.options!=null){return true;}return false;}
function selectUnselectMatchingOptions(obj,regex,which,only){if(window.RegExp){if(which == "select"){var selected1=true;var selected2=false;}else if(which == "unselect"){var selected1=false;var selected2=true;}else{return;}var re = new RegExp(regex);if(!hasOptions(obj)){return;}for(var i=0;i<obj.options.length;i++){if(re.test(obj.options[i].text)){obj.options[i].selected = selected1;}else{if(only == true){obj.options[i].selected = selected2;}}}}}
function selectMatchingOptions(obj,regex){selectUnselectMatchingOptions(obj,regex,"select",false);}
function selectOnlyMatchingOptions(obj,regex){selectUnselectMatchingOptions(obj,regex,"select",true);}
function unSelectMatchingOptions(obj,regex){selectUnselectMatchingOptions(obj,regex,"unselect",false);}
function sortSelect(obj){var o = new Array();if(!hasOptions(obj)){return;}for(var i=0;i<obj.options.length;i++){o[o.length] = new Option( obj.options[i].text, obj.options[i].value, obj.options[i].defaultSelected, obj.options[i].selected) ;}if(o.length==0){return;}o = o.sort(
function(a,b){if((a.text+"") <(b.text+"")){return -1;}if((a.text+"") >(b.text+"")){return 1;}return 0;});for(var i=0;i<o.length;i++){obj.options[i] = new Option(o[i].text, o[i].value, o[i].defaultSelected, o[i].selected);}}
function selectAllOptions(obj){if(!hasOptions(obj)){return;}for(var i=0;i<obj.options.length;i++){obj.options[i].selected = true;}}
var aIdSelect=new Array();
var j=0;
function moveSelectedOptions(from,to){
 
	if(arguments.length>3){
		var regex = arguments[3];if(regex != ""){
			unSelectMatchingOptions(from,regex);}}
			if(!hasOptions(from)){return;}
			for(var i=0;i<from.options.length;i++)
			{var o = from.options[i]; if(o.selected){if(!hasOptions(to)){var index = 0;}
			else{var index=to.options.length;}to.options[index] = new Option( o.text, o.value, false, false);}}
			for(var i=(from.options.length-1);i>=0;i--)
			{var o = from.options[i];if(o.selected){from.options[i] = null;aIdSelect[j] = o.value; j=j+1;}}
			if((arguments.length<3) ||(arguments[2]==true))
			{sortSelect(from);sortSelect(to);}from.selectedIndex = -1;to.selectedIndex = -1;}
 
function copySelectedOptions(from,to){var options = new Object();if(hasOptions(to)){for(var i=0;i<to.options.length;i++){options[to.options[i].value] = to.options[i].text;}}if(!hasOptions(from)){return;}for(var i=0;i<from.options.length;i++){var o = from.options[i];if(o.selected){if(options[o.value] == null || options[o.value] == "undefined" || options[o.value]!=o.text){if(!hasOptions(to)){var index = 0;}else{var index=to.options.length;}to.options[index] = new Option( o.text, o.value, false, false);}}}if((arguments.length<3) ||(arguments[2]==true)){sortSelect(to);}from.selectedIndex = -1;to.selectedIndex = -1;}
function moveAllOptions(from,to){selectAllOptions(from);if(arguments.length==2){moveSelectedOptions(from,to);}else if(arguments.length==3){moveSelectedOptions(from,to,arguments[2]);}else if(arguments.length==4){moveSelectedOptions(from,to,arguments[2],arguments[3]);}}
function copyAllOptions(from,to){selectAllOptions(from);if(arguments.length==2){copySelectedOptions(from,to);}else if(arguments.length==3){copySelectedOptions(from,to,arguments[2]);}}
function swapOptions(obj,i,j){var o = obj.options;var i_selected = o[i].selected;var j_selected = o[j].selected;var temp = new Option(o[i].text, o[i].value, o[i].defaultSelected, o[i].selected);var temp2= new Option(o[j].text, o[j].value, o[j].defaultSelected, o[j].selected);o[i] = temp2;o[j] = temp;o[i].selected = j_selected;o[j].selected = i_selected;}
function moveOptionUp(obj){if(!hasOptions(obj)){return;}for(i=0;i<obj.options.length;i++){if(obj.options[i].selected){if(i != 0 && !obj.options[i-1].selected){swapOptions(obj,i,i-1);obj.options[i-1].selected = true;}}}}
function moveOptionDown(obj){if(!hasOptions(obj)){return;}for(i=obj.options.length-1;i>=0;i--){if(obj.options[i].selected){if(i !=(obj.options.length-1) && ! obj.options[i+1].selected){swapOptions(obj,i,i+1);obj.options[i+1].selected = true;}}}}
function removeSelectedOptions(from){if(!hasOptions(from)){return;}if(from.type=="select-one"){from.options[from.selectedIndex] = null;}else{for(var i=(from.options.length-1);i>=0;i--){var o=from.options[i];if(o.selected){from.options[i] = null;}}}from.selectedIndex = -1;}
function removeAllOptions(from){if(!hasOptions(from)){return;}for(var i=(from.options.length-1);i>=0;i--){from.options[i] = null;}from.selectedIndex = -1;}
function addOption(obj,text,value,selected){if(obj!=null && obj.options!=null){obj.options[obj.options.length] = new Option(text, value, false, selected);}}
function tabId(){
	var len= aIdSelect.length;
	for(var i=0;i<len;i++)
		alert(aIdSelect[i]);
 
	}
 
function submitlist(){
	for(i=0; i<this.elements('list2[]').length;i++) this.elements('liste2[]')[i].selected=true;
	document.MyForm1.submit();
 
}	
 
</script>
<style>
fieldset {padding: 8px;margin: 4px;-moz-border-radius: 8px;}
.rubrique {padding-left:20px;float:left;padding-right:5px; }
.rubrique1 { padding-buttom:30px;}
.txt_cont {font-family: Arial, Helvetica, sans-serif;font-size: 11px;font-weight:100;color: #5A5A5A;text-align:justify;}
.SelUrl { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; font-style: normal;line-height: normal; font-weight: normal; font-variant: normal;  color: #000000; width: 140px; height: 18px;}
.bggris td {BORDER-RIGHT: #8b8b8b 1px solid; BORDER-TOP: #8b8b8b 1px solid; FONT-SIZE: 11px; BORDER-LEFT: #8b8b8b 1px solid; BORDER-BOTTOM: #8b8b8b 1px solid; }
.formbouton { background-color: #CCCCCC; border: 1px #666666 solid; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; color: #333333 }
</style>
 
 
 
 
<table border="0" width="100%"><tr><td align="left" valign="top" width="100%">
 
<form name="MyForm1" action="configselection.php" method="POST">
 
 
<table cellpadding="2" width="100%">
  <tr>
    <td colspan="3" style="text-align:justify"><strong><br>
</strong></td>
  </tr>
  <tr>
    <td><strong>Choisir votre langue</strong></td>
    <td><?=affSelectRange();?><?=affSelectLang($aLang);?></td>
  </tr>
  <tr>
    <td colspan="3"><hr></td>
  </tr>
  </table>
<table border="0">
<tbody><tr>
	<td><?=affSelect1Jeux($aResults);?>
 
 
	</td>
	<td align="center" valign="middle">
		<input name="right" value="&gt;&gt;" onClick="moveSelectedOptions(this.form['list1'],this.form['list2'],false); submitlist()" type="button"><br><br>
 
		<input name="left" value="&lt;&lt;" onClick="moveSelectedOptions(this.form['list2'],this.form['list1'],false)" type="button"><br><br>
 
	</td>
	<td><?=affSelectedJeux();?>
 
	</td>
</tr>
</table>
<table>
<tr><td><strong>Previews</strong></td>
<td><?=affichepreviews()?></td>
</tr>
<tr><td><strong>&nbsp;</strong></td>
 
<td align="right"><br><br><input type="button" name="upload" value="upload"></td></tr>
</table>
 
 
 
</form>
 
</td></tr></tbody></table>
 
 
</body></html>
merci de votre aide