อยากทราบวิธีการดึงค่าจาก list box ออกมาอะค่ะ

คือมีไฟล์ untitle6.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=windows-874" />
<title>Untitled Document</title>
</head>

<body bgcolor="#F0FFF0">
<?
     $val=$_GET['value'];
 echo"$val";
?>

<input type="text" name="nn1" value="<?=$val?>" />
<?    
     echo "<form name=sel>
";
     echo "หมวดเงิน : <font id=budget><select>
";
     echo "<option value='0'>========================</option>
" ;
     echo "</select></font>
";
    
     echo "ประเภทเงิน : <font id=budgetsup><select>
";
     echo "<option value='0'>========================</option>
" ;
     echo "</select></font>
";
  echo "<br>";
   echo "<br>";
   echo "$id";
    
     echo "ประเภทครุภัณฑ์ : <font id=tparcel><select>
";
     echo "<option value='0'>========================</option>
" ;
     echo "</select></font>
";

     echo "ชนิดครุภัณฑ์ : <font id=kparcel><select>
";
     echo "<option value='0'>========================</option>
" ;
     echo "</select></font>
";
   echo "<br>";
   echo "<br>";
  
   echo "รูปแบบการจ่ายเงิน : <font id=typepay><select>
";
     echo "<option value='0'>========================</option>
" ;
     echo "</select></font>
";
   echo "<br>";
    echo "<br>"; 

     echo "บริษัท : <font id=company><select>
";
     echo "<option value='0'>========================</option>
" ;
     echo "</select></font>
";
   echo "<br>";
    echo "<br>";
   
     echo "ผู้เบิก : <font id=personal><select>
";
     echo "<option value='0'>========================</option>
" ;
     echo "</select></font>
";
   echo "<br>";
    echo "<br>"; 

     echo "หน่วยงานหลัก : <font id=uncsfac><select>
";
     echo "<option value='0'>========================</option>
" ;
     echo "</select></font>
";
   
     echo "หน่วยงานย่อย : <font id=department><select>
";
     echo "<option value='0'>========================</option>
" ;
     echo "</select></font>
";
   echo "<br>";
   echo "<br>";
   
?>

<script language=Javascript>
function Inint_AJAX() {
   try { return new ActiveXObject("Msxml2.XMLHTTP");  } catch(e) {} //IE
   try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {} //IE
   try { return new XMLHttpRequest();          } catch(e) {} //Native Javascript
   alert("XMLHttpRequest not supported");
   return null;
};

function dochange(src, val) {
     var req = Inint_AJAX();
     req.onreadystatechange = function () {
          if (req.readyState==4) {
               if (req.status==200) {
                    document.getElementById(src).innerHTML=req.responseText; //รับค่ากลับมา
               }
          }
     };
     req.open("GET", "Untitled7.php?data="+src+"&val="+val); //สร้าง connection
     req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=tis-620"); // set Header
     req.send(null); //ส่งค่า
}
window.onLoad=dochange('budget', -1);    
</script>

</body>
</html>
 

//---------------------------------------------------------------------------------------------------------------------------------------

แล้วก็มีไฟล์ untitle7.php

<?
   $data=$_GET['data'];
     $val=$_GET['val'];

error_reporting(E_ALL ^ E_NOTICE);
$dbhost = "localhost";   
$dbname = "comcenter";  
$dbuser = "root"; 
$dbpass = "";


mysql_connect($dbserver,$dbuser ,$dbpass) or die("เชื่อมต่อฐานข้อมูลไม่ได้");
mysql_query("set NAMES tis620 ");
mysql_select_db($dbname) or die("เลือกฐานข้อมูลไม่ได้");
     
    if ($data=='budget') {
          echo "<select name='budget' onChange=\"dochange('budgetsup', this.value)\">
";
          echo "<option value='0'>------------ เลือกหมวดเงิน ----------</option>
";
          $result=mysql_db_query($dbname,"select  budget_id,budget_name  from budget  where budget_name=budget_name order by  budget_id");
          while(list($id, $name)=mysql_fetch_array($result)){
               echo "<option value=\"$id\" >$name</option>
" ;
          }
     }
     else if ($data=='budgetsup') {
          echo "<select name='budgetsup' onChange=\"dochange('tparcel', this.value)\">
";
          echo "<option value='0'>------------ เลือกประเภทเงิน ------------</option>
";
          $val2=$val;                           
          $result=mysql_db_query($dbname,"SELECT budsup_id,budgetsup_name,budget_id FROM budgetsuptype  WHERE  budget_id ='$val2'  ORDER BY budsup_id ");
          while(list($id, $name)=mysql_fetch_array($result)){      
               echo "<option value=\"$id\" >$name</option>
" ;
          }
     }
     else  if ($data=='tparcel') {
          echo "<select name='tparcel' onChange=\"dochange('kparcel', this.value)\">
";
          echo "<option value='0'>------------ เลือกประเภทครุภัณฑ์ ----------</option>
";
          $result=mysql_db_query($dbname,"select  tparcel_id,tparcel_name  from type_parcel  order by  tparcel_id");
          while(list($id, $name)=mysql_fetch_array($result)){
               echo "<option value=\"$id\" >$name</option>
" ;
          }
     } 
     else if ($data=='kparcel') {
          echo "<select  name='kparcel' onChange=\"dochange('typepay', this.value)\">
";
          echo "<option value='0'>------------ เลือกชนิดครุภัณฑ์ ----------</option>
";
          $val3=$val;
          $result=mysql_db_query($dbname,"SELECT kparcel_id,kparcel_name FROM kind_parcel  WHERE tparcel_id  ='$val3' ORDER BY kparcel_id");
          while(list($id, $name)=mysql_fetch_array($result)){
           echo "<option value=\"$id\" >$name</option>
" ;
          }
     }
   else if ($data=='typepay') {
          echo "<select  name='kparcel' onChange=\"dochange('company', this.value)\">
";
          echo "<option value='0'>------------ เลือกรูปแบบการจ่ายเงิน ----------</option>
";
          $val3=$val;
          $result=mysql_db_query($dbname,"SELECT tp_id,tp_name FROM typepay  ORDER BY  tp_id");
          while(list($id, $name)=mysql_fetch_array($result)){
           echo "<option value=\"$id\" >$name</option>
" ;
          }
     }
    else if ($data=='company') {
          echo "<select name='company' onChange=\"dochange('personal', this.value)\">
";
          echo "<option value='0'>------------ เลือกบริษัท ----------</option>
";
          $result=mysql_db_query($dbname,"select  com_id,com_name  from company  order by  com_id");
          while(list($id, $name)=mysql_fetch_array($result)){
               echo "<option value=\"$id\" >$name</option>
" ;
          }
    }
    else if ($data=='personal') {
          echo "<select name='personal' onChange=\"dochange('uncsfac', this.value)\">
";
          echo "<option value='0'>------------ เลือกบุคคล ----------</option>
";
          $result=mysql_db_query($dbname,"select  per_id,per_name  from personal  order by  per_id");
          while(list($id, $name)=mysql_fetch_array($result)){
               echo "<option value=\"$id\" >$name</option>
" ;
          }
    }
    else  if ($data=='uncsfac') {
          echo "<select name='uncsfac' onChange=\"dochange('department', this.value)\">
";
          echo "<option value='0'>------------ เลือกหน่วยงาน ----------</option>
";
          $result=mysql_db_query($dbname,"select  uncsfac_id,uncsfac_name  from uncsfac  order by  uncsfac_id");
          while(list($id, $name)=mysql_fetch_array($result)){
               echo "<option value=\"$id\" >$name</option>
" ;
          }
     } 
      else if ($data=='department') {
          echo "<select  name='department' >
";
          echo "<option value='0'>======== เลือกหน่วยงานย่อย ========</option>
";
          $val4=$val;
          $result=mysql_db_query($dbname,"SELECT department_id,department_name FROM department  WHERE uncsfac_id  ='$val4' ORDER BY department_id");
          while(list($id, $name)=mysql_fetch_array($result)){
               echo "<option value=\"$id\" >$name</option>
" ;
          }
     }
     echo "</select>
"; 
?>

//---------------------------------------------------------------------------------------------------------------------------------------

แล้วก็มีฐานข้อมูล


CREATE TABLE uncsfac (
       uncsfac_id           INTEGER NOT NULL,
       uncsfac_name         VARCHAR(500) NULL,
       PRIMARY KEY (uncsfac_id)
);


CREATE TABLE department (
       department_id        INTEGER NOT NULL,
       department_name      VARCHAR(500) NULL,
       uncsfac_id           INTEGER NULL,
       PRIMARY KEY (department_id),
       FOREIGN KEY (uncsfac_id)
                             REFERENCES uncsfac
);


CREATE TABLE personal (
       per_id               INTEGER NOT NULL,
       per_name             VARCHAR(250) NULL,
       department_id        INTEGER NULL,
       uncsfac_id           INTEGER NULL,
       PRIMARY KEY (per_id),
       FOREIGN KEY (uncsfac_id)
                             REFERENCES uncsfac,
       FOREIGN KEY (department_id)
                             REFERENCES department, 
    );


CREATE TABLE company (
       com_id               INTEGER NOT NULL,
       com_name             VARCHAR(500) NULL,
       com_no               VARCHAR(100) NULL,
       com_address          VARCHAR(500) NULL,
       PRIMARY KEY (com_id)
);


CREATE TABLE budget (
       budget_id            INTEGER NOT NULL,
       budget_code          VARCHAR(60) NULL,
       budget_name          VARCHAR(50) NULL,
       budget_namesort      VARCHAR(50) NULL,
       PRIMARY KEY (budget_id)
);


CREATE TABLE budgetsuptype (
       budsup_id            INTEGER NOT NULL,
       budget_id            INTEGER NOT NULL,
       budgetsup_code       VARCHAR(60) NULL,
       budgetsup_name       VARCHAR(500) NULL,
       budgetsup_namesort   VARCHAR(50) NULL,
       PRIMARY KEY (budsup_id, budget_id),
       FOREIGN KEY (budget_id)
                             REFERENCES budget
);


CREATE TABLE typepay (
       tp_id                INTEGER NOT NULL,
       tp_code              VARCHAR(60) NULL,
       tp_name              VARCHAR(500) NULL,
       PRIMARY KEY (tp_id)
);


CREATE TABLE type_parcel (
       tparcel_id           INTEGER NOT NULL,
       tparcel_code         VARCHAR(60) NULL,
       tparcel_name         VARCHAR(500) NULL,
       PRIMARY KEY (tparcel_id)
);


CREATE TABLE kind_parcel (
       kparcel_id           INTEGER NOT NULL,
       tparcel_id           INTEGER NOT NULL,
       kparcel_code         VARCHAR(60) NULL,
       kparcel_name         VARCHAR(500) NULL,
       devalue              FLOAT NULL,
       useful_life          FLOAT NULL,
       next_number          INTEGER NULL,
       PRIMARY KEY (kparcel_id, tparcel_id),
       FOREIGN KEY (tparcel_id)
                             REFERENCES type_parcel
);

//--------------------------------------------------------------------------------------------------------------------------------------------

คืออยากเอาค่าให้มันแสดงใน  input type="text"  อะค่ะ แต่ไม่รู้วิธีที่จะส่งค่ากลับมายังหน้า untitle6.php อะค่ะ คือเพิ่งกำลังเริ่มต้นเรื่อง Ajax ด้วยเลยยังงงอยู่  ใครช่วยได้ขอความกรุณาด้วยนะคะ ขอบคุณค่า

 

21 ต.ค. 2551 เวลา 14:35 น. 4 5,715
^