|
 |
|
เลือกข้อมูลใน list menu แล้วให้ข้อมูลขึ้นมาโชว์ใน text box อัตโนมัตค่ะ |
|
 |
|
|
 |
 |
|
Code (PHP)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('#select').change(function(e){
$.ajax({
type: "POST",
url: "test2.php",
data: "user="+$(this).val(),
success: function(msg){
//alert( "Data Saved: " + msg );
$('#result').html(msg);
}
});
})
});
</script>
</head>
<body>
<select name="select" id="select">
<option value="">เลือกคนที่จะแสดง</option>
<option value="1">คนที่ 1</option>
<option value="2">คนที่ 2</option>
<option value="3">คนที่ 3</option>
<option value="4">คนที่ 4</option>
<option value="5">คนที่ 5</option>
</select>
<br />
<br />
<div id="result"></div>
</body>
</html>
test2.php
Code (PHP)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
switch($_POST['user']){
case "1":
echo "ข้อมูลของคนที่ 1";
break;
case "2":
echo "ข้อมูลของคนที่ 2";
break;
case "3":
echo "ข้อมูลของคนที่ 3";
break;
case "4":
echo "ข้อมูลของคนที่ 4";
break;
case "5":
echo "ข้อมูลของคนที่ 5";
break;
default :
echo "ไม่ได้เลือกข้อมูลเลย";
break;
}
?>
</body>
</html>
อาจจะช่วยเป็นตัวอย่างได้บ้างครับ
|
 |
 |
 |
 |
Date :
2010-11-10 14:57:23 |
By :
ไวยวิทย์ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
พอดีว่าทำลิสข้อมูลออกมาโชว์ได้แล้วค่ะ
แต่เวลาเลือกข้อมูลในลิสแล้วให้มันลิงค์กับฐานข้อมูลแล้วดึงออกมาโชว์ในtext box อ่ะค่ะต้องเขียนประมาณไหนค่ะ
ไปไม่เป็นค่ะ
<?
include('connect.php');
$sql_itemno = "select ITEM_NO,ITEM_NAME from item ";
$result_itemno = mysql_query($sql_itemno) or die ("Error Query [".$sql_itemno."]"); ;
?>
<select name="lstItemno" size="1" id="select" onchange="show(this.value);">
<?php
?>
<option value=""> ====> Select Item No<===== </option>
<?
while($result = mysql_fetch_array($result_itemno ))
{
?>
<option value="<?=$result["ITEM_NO"];?>"><?=$result["ITEM_NO"];?>
</option>
<?
}
?>
</select>

อันนี้คือโค้ดดึงข้อมูลมาโชว์ในลิสค่ะ
|
 |
 |
 |
 |
Date :
2010-11-10 15:12:45 |
By :
taewengja |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เหอะ ๆ
คุณต้องทำความเข้าใจก่อนว่ามันทำงานยังไงครับ ไม่ใช่อยากได้ ๆ ท่าเดียวครับ
|
 |
 |
 |
 |
Date :
2010-11-10 15:19:07 |
By :
ไวยวิทย์ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
อิอิอิ ค่ะ ขอบคุณค่ะที่แนะนำ
|
 |
 |
 |
 |
Date :
2010-11-10 15:23:36 |
By :
taewengja |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 02
|