เขียน AJAX แล้วไม่สามารถรันบน google chrome ได้คะ
โปรแกรมโดยรวมคือ เช็ค radio box แล้วจะไปแสดงคำนวณค่าจัดส่งในหน้า ship_cal.php
และจะมีปุ่มหน้าถัดไปแสดงขึ้นมา
ลองเทสแล้ว google chrome ไม่สามารถแสดงปุ่มขึ้นมาได้เมื่อ check radio box คะ
โค๊ดมีดังนี้คะ
ส่วน head ที่ใส่โค๊ด ajax
<script language="javascript">
function shipping(type) {
document.getElementById('shipping').innerHTML="";
var product;
if (window.ActiveXObject) {
product = new ActiveXObject("Microsoft.XMLHTTP");
}
else if (window.XMLHttpRequest) {
product = new XMLHttpRequest();
}
product.onreadystatechange = function()
{
if(product.readyState == 4) {
document.getElementById('shipping').innerHTML = product.responseText;
}
}
product.open("GET","ship_cal.php?ship_type=" type,true);
document.getElementById('next').innerHTML="<input type='submit' name='submit' id='submit' value='หน้าถัดไป' >";
product.send(null);
}
function openfile(file){
window.location=file;
}
</script>
body
<?php
include("../../include/connect.php");
$sql="select * from shipping";
$query=mysql_query($sql);
$num=mysql_num_rows($query);
for($i=0;$i<$num;$i ){
$rs=mysql_fetch_array($query);
echo "<p><input type='radio' name='RadioGroup1' value='$rs[id_ship]' id='RadioGroup1_0' onfocus="shipping('$rs[id_ship]')" />$rs[type_ship]</p>";
}
?>
<p align="center">
<div id="shipping" align="center"></div> //แสดงราคาค่าจัดส่ง
</p>
<form id="form1" name="tran" method="post" action="shipadd.php">
<table width="100%" border="0" cellspacing="10" cellpadding="10">
<tr>
<td align="center"><table width="260" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="60"><input type="button" name="button" id="button" value="ก่อนหน้า" onclick="openfile('basket.php')"></td>
<td width="100"><input type="button" name="button2" id="button2" value="เลือกสินค้าเพิ่ม" onclick="openfile('../../index.html')"></td>
<td width="100"><div id="next"></div></td> //แสดงปุ่ม
</tr>
</table></td>
</tr>
</table>
</form>