|
|
|
ขอถามเรื่อง popup colorbox ไม่ขึ้นในหน้า php โดยใช้ ajax ครับ |
|
|
|
|
|
|
|
ต้องเอาโค้ดล่าสุดมาให้ดูครับ
|
|
|
|
|
Date :
2012-05-13 14:50:34 |
By :
sakuraei |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ตัวนี้คือ add_substock_ajax.php
Code (PHP)
<?php require_once('Connections/stock.php'); ?>
<?
mysql_select_db($database_stock, $stock);
$query_substock = "select code,name from doctor where position_id in ('3','7')";
$substock = mysql_query($query_substock, $stock) or die(mysql_error());
$row_substock = mysql_fetch_assoc($substock);
$totalRows_substock = mysql_num_rows($substock);
?>
<!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>
<script type="text/javascript">
//load list by sort
var HttPRequest = false;
function doCallAjax() {
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 = 'add_substock_ss.php';
var pmeters = '';
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("displayDiv2").innerHTML = "Now is Loading...";
}
if(HttPRequest.readyState == 4) // Return Request
{
document.getElementById("displayDiv2").innerHTML = HttPRequest.responseText;
}
}
}
</script>
<script src="include/ajax_framework.js"></script>
<style>
body{font:12px/1.2 Verdana, sans-serif; padding:0 10px;}
a:link, a:visited{text-decoration:none; color:#416CE5; border-bottom:1px solid #416CE5;}
h2{font-size:13px; margin:15px 0 0 0;}
</style>
<link rel="stylesheet" href="./css/colorbox.css" />
<script src="./include/jquery.js"></script>
<script src="./include/jquery.colorbox.js"></script>
<script>
$(document).ready(function(){
//Examples of how to assign the ColorBox event to elements
$(".iframe").colorbox({iframe:true, width:"800", height:"600"});
//Example of preserving a JavaScript event for inline calls.
$("#click").click(function(){
$('#click').css({"background-color":"#f00", "color":"#fff", "cursor":"inherit"}).text("Open this window again and this message will still be here.");
return false;
});
});
</script>
<style type="text/css">
<!--
.style10 {color: #000000; font-size: 14; }
.style7 {font-size: 14}
.style11 {
color: #FF0000;
font-weight: bold;
font-size: 16px;
}
-->
</style>
</head>
<body Onload="JavaScript:doCallAjax();">
<p class="style11">กำหนดคลังย่อย</p>
<input name="button1" type="button" id="button1" value="เพิ่ม" onclick="formShow()" />
<form id="frm">
<table width="500" border="0" cellspacing="1" cellpadding="1" id="form" >
<tr>
<td width="52%" align="center"><span class="style10">ชื่อคลังย่อย
<input name="item_id" type="hidden" id="item_id" />
</span></td>
<td width="12%" align="center">ผู้รับผิดชอบ</td>
<td width="16%" align="center">ใช้งาน</td>
<td width="10%" align="center"><input name="do" type="hidden" id="do" value="<? echo "insert"; ?>" /></td>
</tr>
<tr>
<td align="center"><label>
<input name="substock_name" type="text" id="substock_name"/>
</label></td>
<td align="center"><select name="doctor" id="doctor">
<?php
do {
?>
<option value="<?php echo $row_substock['code']?>"<?php if (!(strcmp($row_substock['code'], $row_edit['administrator']))) {echo "selected=\"selected\"";} ?>><?php echo $row_substock['name']?></option>
<?php
} while ($row_substock = mysql_fetch_assoc($substock));
$rows = mysql_num_rows($substock);
if($rows > 0) {
mysql_data_seek($substock, 0);
$row_substock = mysql_fetch_assoc($substock);
}
?>
</select></td>
<td align="center"><input <?php if (!(strcmp($row_edit['active'],"Y"))) {echo "checked=\"checked\"";} ?> name="active" type="checkbox" id="active" value="Y" /></td>
<td align="center"><span class="style7">
<label>
<input name="button" type="button" id="button" />
</label>
</span></td>
</tr>
</table>
<br />
</form>
<div id="indicator" align="center"
style="position:absolute; display:none; z-index:1000;padding:0px;"> <img src="images/indicator.gif" hspace="10" align="absmiddle" /> </div>
<div id="displayDiv2" ></div>
</body>
</html>
<?php
mysql_free_result($substock);
?>
และ add_substock_ss.php
Code (PHP)
<?php require_once('Connections/stock.php'); ?>
<?
mysql_select_db($database_stock, $stock);
$query_substock = "select code,name from doctor where position_id in ('3','7')";
$substock = mysql_query($query_substock, $stock) or die(mysql_error());
$row_substock = mysql_fetch_assoc($substock);
$totalRows_substock = mysql_num_rows($substock);
?>
<!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>
<script type="text/javascript">
//load list by sort
var HttPRequest = false;
function doCallAjax() {
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 = 'add_substock_ss.php';
var pmeters = '';
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("displayDiv2").innerHTML = "Now is Loading...";
}
if(HttPRequest.readyState == 4) // Return Request
{
document.getElementById("displayDiv2").innerHTML = HttPRequest.responseText;
}
}
}
</script>
<script src="include/ajax_framework.js"></script>
<style>
body{font:12px/1.2 Verdana, sans-serif; padding:0 10px;}
a:link, a:visited{text-decoration:none; color:#416CE5; border-bottom:1px solid #416CE5;}
h2{font-size:13px; margin:15px 0 0 0;}
</style>
<link rel="stylesheet" href="./css/colorbox.css" />
<script src="./include/jquery.js"></script>
<script src="./include/jquery.colorbox.js"></script>
<script>
$(document).ready(function(){
//Examples of how to assign the ColorBox event to elements
$(".iframe").colorbox({iframe:true, width:"800", height:"600"});
//Example of preserving a JavaScript event for inline calls.
$("#click").click(function(){
$('#click').css({"background-color":"#f00", "color":"#fff", "cursor":"inherit"}).text("Open this window again and this message will still be here.");
return false;
});
});
</script>
<style type="text/css">
<!--
.style10 {color: #000000; font-size: 14; }
.style7 {font-size: 14}
.style11 {
color: #FF0000;
font-weight: bold;
font-size: 16px;
}
-->
</style>
</head>
<body Onload="JavaScript:doCallAjax();">
<p class="style11">กำหนดคลังย่อย</p>
<input name="button1" type="button" id="button1" value="เพิ่ม" onclick="formShow()" />
<form id="frm">
<table width="500" border="0" cellspacing="1" cellpadding="1" id="form" >
<tr>
<td width="52%" align="center"><span class="style10">ชื่อคลังย่อย
<input name="item_id" type="hidden" id="item_id" />
</span></td>
<td width="12%" align="center">ผู้รับผิดชอบ</td>
<td width="16%" align="center">ใช้งาน</td>
<td width="10%" align="center"><input name="do" type="hidden" id="do" value="<? echo "insert"; ?>" /></td>
</tr>
<tr>
<td align="center"><label>
<input name="substock_name" type="text" id="substock_name"/>
</label></td>
<td align="center"><select name="doctor" id="doctor">
<?php
do {
?>
<option value="<?php echo $row_substock['code']?>"<?php if (!(strcmp($row_substock['code'], $row_edit['administrator']))) {echo "selected=\"selected\"";} ?>><?php echo $row_substock['name']?></option>
<?php
} while ($row_substock = mysql_fetch_assoc($substock));
$rows = mysql_num_rows($substock);
if($rows > 0) {
mysql_data_seek($substock, 0);
$row_substock = mysql_fetch_assoc($substock);
}
?>
</select></td>
<td align="center"><input <?php if (!(strcmp($row_edit['active'],"Y"))) {echo "checked=\"checked\"";} ?> name="active" type="checkbox" id="active" value="Y" /></td>
<td align="center"><span class="style7">
<label>
<input name="button" type="button" id="button" />
</label>
</span></td>
</tr>
</table>
<br />
</form>
<div id="indicator" align="center"
style="position:absolute; display:none; z-index:1000;padding:0px;"> <img src="images/indicator.gif" hspace="10" align="absmiddle" /> </div>
<div id="displayDiv2" ></div>
</body>
</html>
<?php
mysql_free_result($substock);
?>
|
ประวัติการแก้ไข 2012-05-13 15:53:20 2012-05-13 15:58:47
|
|
|
|
Date :
2012-05-13 15:52:22 |
By :
kohrx |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
รบกวนหน่อยนะครับ พี่ๆ
|
|
|
|
|
Date :
2012-05-14 19:02:20 |
By :
kohrx |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|