 |
|
@@@@@@@@@@@@@@@@@@@@@@@@@@@@choose_receiver.php@@@@@@@@@@@@@@@@@@@@@@@@@@@
<form name="form" action="<?php $_SERVER['PHP_SELF'] ?>" method="post">
<script language="JavaScript" type="text/javascript" src="../DBFunc/choose_receiver.js" ></script>
<select name="personallist" id="personallist"onChange="location.href='choose_receiver.php?id_depart='+this.value;" ><!--onChange="document.form1.submit();"-->
<option value="" selected="selected">เลือกแผนก.....เพื่อทำการเลือกรายชื่อพนักงาน</option>
<? //this.options[this.selectedIndex].value;
$sql="select id_depart, name_depart from $tbl_name1 order by id_depart ASC";
$dbquery=mysql_db_query($dbname,$sql);
while($result=mysql_fetch_array($dbquery)){
if($id_depart == $result[id_depart]){
?>
<option value="<?=$result[id_depart];?>" ><?=$result[name_depart];?></option>
<?
}else{
?>
<option value="<?=$result[id_depart];?>"><?=$result[name_depart];?></option>
<?
}
}
?>
</select>
<?php
$users = mysql_query("SELECT id_user, name_user FROM $tbl_name8 where id_depart='$id_depart'");
?>
<table width="207" border="0">
<tr>
<td width="100">
<select name="sel1" size="10" multiple="multiple" style="width: 200px" />
<?php
while ($row = mysql_fetch_array($users)) {
print "<option value=\"{$row['id_user']}\">{$row['name_user']}</option>\n";
} ?>
</select>
</td>
<td width="48" align="center" valign="middle">
<input type="button" value="-->" onClick="moveOptions(this.form.sel1, this.form.sel2);" />
<input type="button" value="<--" onClick="moveOptions(this.form.sel2, this.form.sel1);" />
</td>
<td width="45">
<select name="sel2" size="10" multiple="multiple" style="width: 200px" />
</select>
</td>
</tr>
</table>
<input type="submit" name="submit" value="ทดสอบ" />
</form>
@@@@@@@@@@@@@@@@@@@@@@@@@@@@choose_receiver.js@@@@@@@@@@@@@@@@@@@@@@@@@@@@
var NS4 = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) < 5);
function addOption(theSel, theText, theValue)
{
var newOpt = new Option(theText, theValue);
var selLength = theSel.length;
theSel.options[selLength] = newOpt;
}
function deleteOption(theSel, theIndex)
{
var selLength = theSel.length;
if(selLength>0)
{
theSel.options[theIndex] = null;
}
}
function moveOptions(theSelFrom, theSelTo)
{
var selLength = theSelFrom.length;
var selectedText = new Array();
var selectedValues = new Array();
var selectedCount = 0;
var i;
// Find the selected Options in reverse order
// and delete them from the 'from' Select.
for(i=selLength-1; i>=0; i--)
{
if(theSelFrom.options.selected)
{
selectedText[selectedCount] = theSelFrom.options.text;
selectedValues[selectedCount] = theSelFrom.options.value;
deleteOption(theSelFrom, i);
selectedCount++;
}
}
// Add the selected text/values in reverse order.
// This will add the Options to the 'to' Select
// in the same order as they were in the 'from' Select.
for(i=selectedCount-1; i>=0; i--)
{
addOption(theSelTo, selectedText, selectedValues);
}
if(NS4) history.go(0);
}
//-->
function getSelected(opt) {
var selected = new Array();
var index = 0;
for (var intLoop=0; intLoop < opt.length; intLoop++) {
if (opt[intLoop].selected) {
index = selected.length;
selected[index] = new Object;
selected[index].value = opt[intLoop].value;
selected[index].index = intLoop;
}
}
return selected;
}
function outputSelected(opt) {
var sel = getSelected(opt);
var strSel = "";
for (var item in sel)
strSel += sel[item].value + "\n";
alert("Selected Items:\n" + strSel);
}
คือผมต้องการเลือกค่าแผนกจาก dropdownlist (ซึ่งค่าแผนกใน dropdownlist มาจากฐานข้อมูล) จากนั้นก็จะไปแสดงรายชื่อพนักงานใน listbox1(ชื่อ sel1) หลังจากนั้นผู้ใช้ก็จะทำการเลือกชื่อพนักงาน ซึ่งสามารถเลือกได้หลายคน แล้วกดปุ่มย้ายไป listbox2(ชื่อ sel2) ปัญหาของผมอยู่ที่ ผมจะเอาค่าจาก listbox2 ออกมาได้อย่างไรครับ เพราะว่าผมต้องการเอาค่ารหัสของพนักงานที่ถูกเลือกไปใช้ต่อ
Tag : - - - -
|
|
 |
 |
 |
 |
Date :
11 ก.ย. 2551 09:47:10 |
By :
Greatboy |
View :
1739 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |