พอดีผมต้องการให้ค่าที่อยู่ใน textbox อันที่ 2 นั้นแสดงข้อมูลเป็น text ($data3[proposal]) แต่ส่งค่าเป็น ตัวเลขไปอ่ะครับ select_stat2.php(PHP)
<?
$id=$_GET['id'];
require "../connect.php";
$q=mysql_query("select distinct project_id from evaluation where teacher_id='$id'");
echo mysql_error();
$myarray=array();
$str="";
while($nt=mysql_fetch_array($q)){
$sql3="SELECT * FROM project WHERE project_id='$nt[project_id]' ";
$query3=mysql_query($sql3);
while($data3=mysql_fetch_array($query3)){
$str=$str . "\"$data3[project_id]\"".","; //ค่าที่ส่งไปเป็นตัวเลข
}
}
$str=substr($str,0,(strLen($str)-1)); // Removing the last char , from the string
echo "new Array($str)";
?>
select_stat3.php (PHP)
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<script type="text/javascript">
function AjaxFunction(id)
{
var httpxml;
try
{
// Firefox, Opera 8.0+, Safari
httpxml=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
httpxml=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
httpxml=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
alert("Your browser does not support AJAX!");
return false;
}
}
}
function stateck()
{
if(httpxml.readyState==4)
{
var myarray=eval(httpxml.responseText);
// Before adding new we must remove previously loaded elements
for(j=document.testform.project.options.length-1;j>=0;j--)
{
document.testform.project.remove(j);
}
for (i=0;i<myarray.length;i++)
{
var optn = document.createElement("OPTION");
optn.text = myarray[i];
optn.value = myarray[i];
document.testform.project.options.add(optn);
}
}
}
var url="select_stat2.php";
url=url+"?id="+id;
url=url+"&sid="+Math.random();
httpxml.onreadystatechange=stateck;
httpxml.open("GET",url,true);
httpxml.send(null);
}
</script>
<form name="testform" method='POST' action='select_stat4.php'><select name="teacher" onChange="AjaxFunction(this.value);">
<option value=''>Select One</option>
<?
require "../connect.php";// connection to database
$q=mysql_query("select * from teacher");
mysql_query("set names utf8");
while($n=mysql_fetch_array($q)){
echo "<option value=$n[teacher_id]>$n[t_name] $n[t_surname]</option>";
}
?>
</select>
<select name="project">
</select><input type="submit" value="submit">
</form>
</body>
</html>