|
|
|
เคยเจอปัญหาแบบนี้ไหมครับ ผมรับค่ามาจาก list/menu 2 ตัว คือ country กับ city โดย 2 ตัวนี้ใช้ ajax ตอนรับค่ามาก็ $_POST["country"] |
|
|
|
|
|
|
|
เดาว่าเหมือนกันครับเป็นที่ FF
|
|
|
|
|
Date :
2009-10-08 11:59:04 |
By :
NanoThoro |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
พอจะมีทางแก้ไหมครับ คุณนาโน
|
|
|
|
|
Date :
2009-10-08 12:00:49 |
By :
นาย |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอดูโค้ดหน่อยครับ
|
|
|
|
|
Date :
2009-10-08 12:05:11 |
By :
xbeginner01 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
charter-req.php
Code (PHP)
<script type="text/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("POST", "getcountry.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('country', -1);
</script>
// list/menu country
echo "<font id='country'><select style='width: 120px; border: 1px solid #336699;'>\n";
echo "<option value='0'>--------------------</option> \n" ;
echo "</select></font>\n";
// list/menu city
echo "<font id='city'><select style='width: 120px; border: 1px solid #336699;'>\n";
echo "<option value='0'></option> \n" ;
echo "</select></font>\n";
getcountry.php
Code (PHP)
include_once("includes/config.inc.php");
header("content-type: application/x-javascript; charset=tis-620");
$data=$_GET['data'];
$val=$_GET['val'];
if ($data=='country') {
$sql="SELECT * FROM country_tbl ORDER BY country_name, country_code";
$result = mysql_query($sql);
echo "<select name='country' id='country' style='width: 120px; border: 1px solid #336699;' onChange=\"dochange('city', this.value)\">\n";
echo "<option value='0'>- Select -</option>\n";
while($fetcharr = mysql_fetch_array($result))
{
$val = $fetcharr['country_code'];
$label = $fetcharr['country_name'];
echo "<option value=\"$val\">$label</option> \n" ;
}
} else if ($data=='city') {
echo "<select name='city' id='city' style='width: 120px; border: 1px solid #336699;' onChange=\"dochange('', this.value)\">\n";
$sql="select * from city_tbl where country_code = '$val'";
$result = mysql_query($sql);
echo "<option value='0'>-- Select --</option>\n";
while($fetcharr = mysql_fetch_array($result))
{
$val = $fetcharr['city_id'];
$label = $fetcharr['city_name'];
echo "<option value=\"$val\">$label</option> \n" ;
}
}
echo "</select>\n";
//fncharter-req.php
Code (PHP)
$country = $_POST["country"];
$city = $_POST["city"];
|
|
|
|
|
Date :
2009-10-08 12:17:37 |
By :
นาย |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<font id='country'> แปลกดี จะส่งไปทั้ง dropdown เลยหรอครับ
ตรง dochange ลอง alert(src); ดูซิ
|
|
|
|
|
Date :
2009-10-08 12:26:37 |
By :
plakrim |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|