รบกวนด้วยครับทำเหมือนจังหวัด อำเภอ ตำบล แต่ทะม่ายไม่ขึ้นอะครับ

<!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"/>
<style type="text/css">
* {
 margin:0;
 padding:0;
}
body {
 font-family:Tahoma;
 font-size:9pt;
 background:#FAF2E6;
}
input,select,option {
 font-family:Tahoma;
 font-size:1em;
 background-color:#FFFFFF;
}
input,select {
 padding:2px;
 border:1px solid navy;
}
option {
 padding-left:2px;
 padding-right:2px;
}
</style>
</head>
<body>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> AJAX</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style type="text/css">
* {
 font-family:Tahoma;
 font-size:8pt;
}
</style>

<form action="" method="post">
<span id="series_nameDiv"><label for="series_name">เลือกซีรี่ย์รถยนต์ :</label><select name="series_name" id="series_name" onchange="dochange('series_name')">
<option value="">--------------</option>
</select></span>
<span id="id_modelDiv"><label for="id_model">เลือกโมเดลรถยนต์ :</label><select name="id_model" id="id_model" onchange="dochange('id_model')">
<option value="">--------------</option>
</select></span>
<span id="code_colorDiv"><label for="code_color">เลือกสีรถยนต์ :</label><select name="code_color" id="code_color">
<option value="">--------------</option>
</select></span>
<br /><br /><br /><input type="submit" value="ส่ง" name="submit" />
</form>
<script type="text/javascript">
//AJAX
function Inint_AJAX()
{
 try
 {
  return new ActiveXObject( "Msxml2.XMLHTTP" );
 }
 catch ( e )
 {
 };

 try
 {
  return new ActiveXObject( "Microsoft.XMLHTTP" );
 }
 catch ( e )
 {
 };

 try
 {
  return new XMLHttpRequest();
 }
 catch ( e )
 {
 };

 alert( "XMLHttpRequest not supported" );
 return null;
};

function dochange( obj )
{
 var req = Inint_AJAX();
 var series_name = document.getElementById( 'series_name' ).value;
 var id_model = document.getElementById( 'id_model' ).value;
 if ( obj && obj.name == 'series_name' ) //เมื่อทำการเลือที่จังหวัดมา ให้เคลียร์ค่าอำเภอ
 {
  var id_model = "";
 }
 else //เลือกรายการอื่น
 {
  var id_model = document.getElementById( 'id_model' ).value;
 };
 var data = "series_name=" + series_name + "&id_model=" + id_model + "&code_color=" + code_color;
 req.onreadystatechange = function()
 {
  if ( req.readyState == 4 )
  {
   if ( req.status == 200 )
   {
    var datas = eval( '(' + req.responseText + ')' ); // JSON
    document.getElementById( 'series_nameDiv' ).innerHTML = datas[0].series_name;
    document.getElementById( 'id_modelDiv' ).innerHTML = datas[0].id_model;
    document.getElementById( 'code_colorDiv' ).innerHTML = datas[0].code_color;
   };
  };
 };
 req.open( "post" , "../../ex/province_utf_sql/province.php" , true ); //สร้าง connection
 req.setRequestHeader( "Content-Type", "application/x-www-form-urlencoded" ); // set Header
 req.send( data ); //ส่งค่า
};

//โหลดครั้งแรก
window.onload = function()
{
 dochange( '' );
};
</script>

</body>
</html>

24 ก.ย. 2552 1 2,142

ตาลายคับพี่น้อง
#1
ความคิดเห็น
ไฟล์อัปโหลด ชนิด jpg, jpeg ขนาดไฟล์ไม่เกิน 1024
^