Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,028

HOME > PHP > PHP Forum > การนำค่า จาก listbox อันที่2 ที่ย้ายมาก listbox อันแรก



 

การนำค่า จาก listbox อันที่2 ที่ย้ายมาก listbox อันแรก

 



Topic : 022038

Guest




@@@@@@@@@@@@@@@@@@@@@@@@@@@@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="--&gt;" onClick="moveOptions(this.form.sel1, this.form.sel2);" />
<input type="button" value="&lt;--" 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 : - - - -







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 11 ก.ย. 2551 09:47:10 By : Greatboy View : 1684 Reply : 1
 

 

No. 1

Guest




Go to : Move Option List/ListMenu เทคนิคการทำเพิ่ม/ลบ/ย้าย Option Items ใน List Menu






Date : 2011-08-07 08:06:26 By : thaicreate
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : การนำค่า จาก listbox อันที่2 ที่ย้ายมาก listbox อันแรก
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 02
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่