 |
|
เพิ่งทำได้เมื่อกี๊ครับ เลือกช่อง text1 แล้ว เอาเม้าไปวางที่ text2 มันก็จะแสดงผลออกมา
ช่วยแนะนำด้วยครับ ผมว่าอันนี้มันลูกทุ่งไปหน่อยอ่ะ
Code (JavaScript)
<script language="JavaScript">
var HttPRequest = false;
function doCallAjax(fProductID,fProductName) {
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 = 'plus30day.php'; //ไฟล์+date 30 วัน
var pmeters = "tProductID=" + encodeURI( document.getElementById(fProductID).value);
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 == 4) // Return Request
{
var myProduct = HttPRequest.responseText;
if(myProduct != "")
{
/*var myArr = myProduct.split("|");*/
document.getElementById(fProductName).value = myProduct;
/*document.getElementById(fProductName).value = myArr[0];
document.getElementById(fPrice).value = myArr[1];*/
}
}
}
}
</script>
Code (PHP)
<?
print <<< HTML
<table>
<tr><td aling='right'>date1 ::</td><td><input type="text" name="min_date" id="min_date" value='$min_date' size="10" OnChange="JavaScript:doCallAjax('min_date','due_date');" onclick="popUpCalendar(this, b.min_date, 'dd/mm/yyyy')">
<img src="../../js/cal.gif" onclick="popUpCalendar(this, b.min_date, 'yyyy-mm-dd')" align="top" width="16" height="16">
</td> </tr>
<tr><td aling='right'>text2 ::</td><td><input type="text" name="due_date" id="due_date" value='$due_date' size="10" readonly OnMouseOver="JavaScript:doCallAjax('min_date','due_date');">
</td> </tr>
</table>
HTML;
?>
อันนี้ใช้คำนวน date + 30 วันครับ
Code (PHP)
<?php
$strProduct = trim($_POST["tProductID"]);
$adddate=30;
Ymd2date($strProduct,$adddate);
return;
function Ymd2date($date1,$adddate) {
list($y1,$m1,$d1) = split("-",$date1);
$d1=(int)$d1;$m1=(int)$m1;$y1=(int)$y1;
$checkdate = mktime(0, 0, 0, $m1, $d1+$adddate, $y1);
echo date("Y-m-d",$checkdate);
return;
};
?>
|
 |
 |
 |
 |
Date :
2011-06-30 11:24:11 |
By :
dbnoon |
|
 |
 |
 |
 |
|
|
 |