|
 |
|
รบกวนสอบถามการ Select ข้อมูล แบบไม่เปลี่ยนหน้า โชว์ตั้งงแต่ตอนแรก นะครับ |
|
 |
|
|
 |
 |
|
ผมต้องการ โชว์ข้อมูล เวลาคลิกที่ url แล้ว Address ไม่เปลี่ยนหน้า ตอนนี้ผมลองใช้ เวลามันเปิดหน้าขึ้นมา ต้องคลิกก่อนถึงจะโชว์ข้อมูล อยากให้โชว์ แบบไม่ค้องคลิก อะครับ
รูปนี้เป็นรูปเปิดหน้าขึ้นมา

พอกดคลิก

ผมใช้ Code ตัวนี้อะครับ
Code (JavaScript)
<script language="JavaScript">
var HttPRequest = false;
function doCallAjax(ID) {
HttPRequest = false;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
HttPRequest = new XMLHttpRequest();
if (HttPRequest.overrideMimeType) {
HttPRequest.overrideMimeType('text/html');
}
} else if (window.ActiveXObject) { // IE
try {
HttPRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
HttPRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!HttPRequest) {
alert('Cannot create XMLHTTP instance');
return false;
}
var url = 'checkpoint.php';
var pmeters = "league=" + ID ;
HttPRequest.open('POST',url,true);
HttPRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
HttPRequest.setRequestHeader("Content-length", pmeters.length);
HttPRequest.setRequestHeader("Connection", "close");
HttPRequest.send(pmeters);
HttPRequest.onreadystatechange = function()
{
if(HttPRequest.readyState == 3) // Loading Request
{
document.getElementById("mySpan").innerHTML = "..";
}
if(HttPRequest.readyState == 4) // Return Request
{
if(HttPRequest.responseText == 'Y')
{
window.location = 'index.php';
return ID;
}
else
{
document.getElementById("mySpan").innerHTML = HttPRequest.responseText;
}
}
}
}
</script>
และ Code PHP
Code (PHP)
<ul name="league" id="league">
<input type="hidden" name="id" id="id" size="30" OnChange="JavaScript:doCallAjax();" value="1"/>
<?php
$query_list=mysql_query("Select * From league where l_delete=0 order by lid");
while($sl < mysql_num_rows($query_list)){
$arrL= mysql_fetch_array($query_list);
?>
<li><a href="JavaScript:doCallAjax('<?=$arrL["lid"];?>');" ><?php echo $arrL['lnamethai'] ?></a></li>
<?php
$sl++;
}
?>
</ul>
Tag : PHP, HTML/CSS, JavaScript, Ajax, jQuery

|
ประวัติการแก้ไข 2014-04-26 23:19:15
|
 |
 |
 |
 |
Date :
2014-04-26 18:48:09 |
By :
notzaclub001 |
View :
1197 |
Reply :
8 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ช่วยแนะนำวิธีอื่นๆ ก็ได้นะครับ
|
 |
 |
 |
 |
Date :
2014-04-27 08:15:41 |
By :
notzaclub001 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|

|
 |
 |
 |
 |
Date :
2014-04-28 09:49:27 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
<a herf="index.php?menu=p">พรีเมียร์<a/>
<a herf="index.php?menu=l">ลาลีกา<a/>
<a herf="index.php?menu=i">กัลโซ่<a/>
<a herf="index.php?menu=g">บุนเดสลีกา<a/>
if(isset($_GET['menu'])) {
$menu = $_GET['menu'];
} else {
$menu = '';
}
switch ($menu) {
case "p":
$src_page = 'england.php';
break;
case "l":
$src_page = 'spain.php';
break;
case "i":
$src_page = 'italy.php';
break;
case "g":
$src_page = 'german.php';
break;
default:
$src_page = 'england.php';//ค่าเริ่มต้นเมื่อเปิดเว็บ จะโชว์ให้ทันที
}
include $src_page;//เอาไปใส่ iframe หรือ include เข้ามาตรง ๆ เลย
?>
|
 |
 |
 |
 |
Date :
2014-04-28 11:31:52 |
By :
apisitp |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Dump ตารางข้อมูลออกมาเป็น SQL แล้วมาโพสต์ พรุ่วนี้ว่างๆเด๋วปรับ ตาราง พร้อม Code ต.ย.ให้...
|
 |
 |
 |
 |
Date :
2014-04-28 22:42:36 |
By :
apisitp |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
</head>
<body>
<?php
$host="localhost";
$user="";
$pw="";
$dbname="guduball_db";
mysql_connect($host,$user,$pw) or die("ติดต่อ Host ไม่ได้");
mysql_select_db($dbname) or die("ติดต่อฐานข้อมูลไม่ได้");
mysql_query("SET NAMES UTF8");
$sql = 'SELECT * FROM `league` ORDER BY lid ASC';
$result = mysql_query($sql) or die ("การเชื่อมต่อมีปัญหากรุณา ค้นหาใหม่อีกครั้ง") ;
$num = mysql_num_rows($result) ;
while($rs = mysql_fetch_array($result))
{
?>
<a href="?menu=<?=$rs['lid']?>"><?=$rs['lnamethai']?></a> |
<?php
}
switch ($_GET["menu"]) {
case "1":
$src_page = 'Premier.php';
break;
case "2":
$src_page = 'Spanish.php';
break;
case "3":
$src_page = 'Thailand.php';
break;
case "4":
$src_page = 'Bundes.php';
break;
case "5":
$src_page = 'Serie.php';
break;
default:
$src_page = 'Premier.php';
}
?>
<br>
<iframe src="<?php echo $src_page; ?>" width="500px" height="800px"></iframe>
</body>
</html>
|
 |
 |
 |
 |
Date :
2014-04-29 09:26:33 |
By :
apisitp |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 02
|