|
|
|
ผมอยากทำ การเช็ก การใส่ข้อมูล ปกติแล้วใช้เป็น onclick แต่ตอนนี้มี onclick ของfunction อื่นอยู่แล้วจะต้องทำยังไงหรือครับ |
|
|
|
|
|
|
|
มันมี onclick ของ function doCallAjax() จะใช้ onclick ของ IsCheck ยังไงดี ครับ
Code (PHP)
<!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=utf-8" />
<title>รายการพิมพ์</title>
<script language="JavaScript">
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;
}
if(confirm('คุณต้องการเพิ่มข้อมูลใช่ไหม')==true)
{
var url = 'fn_formA1_tab1.php?txtCode='+document.getElementById("txtCode").value+'&txtDate='+document.getElementById("txtDate").value
+'&txtName='+document.getElementById("txtName").value+'&SelWork='+document.getElementById("SelWork").value+'&txtOther='+document.getElementById("txtOther").value
+'&txtSize='+document.getElementById("txtSize").value+'&txtSize1='+document.getElementById("txtSize1").value+'&SelSize='+document.getElementById("SelSize").value
+'&txtPage='+document.getElementById("txtPage").value+'&SelBook='+document.getElementById("SelBook").value+'&txt1='+document.getElementById("txt1").value
+'&txt2='+document.getElementById("txt2").value+'&txt3='+document.getElementById("txt3").value+'&txt4='+document.getElementById("txt4").value+'&txt5='+document.getElementById("txt5").value
+'&txtComment='+document.getElementById("txtComment").value+'&txtCus='+document.getElementById("txtCus").value+'&txtEmp='+document.getElementById("txtEmp").value
+'&status='+document.getElementById("status").value;
HttPRequest.open('POST',url,true);
HttPRequest.send(null);
}
HttPRequest.onreadystatechange = function()
{
if(HttPRequest.readyState == 4) // Return Request
{
document.getElementById("mySpan").innerHTML = HttPRequest.responseText;
}
}
/*
HttPRequest.onreadystatechange = call function .... // Call other function
*/
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features).focus();
}
function searchResultSaleman(theURL,winName,features) { //v2.0
window.open(theURL,winName,features).focus();
}
function searchResultSaleman(){
var width = 1100;
var height = 300;
var diaxFeature="dialogWidth:"+width+"px;"
+"dialogHeight:"+height+"px;"
/*+"dialogLeft:"+width+"px;"
+"dialogTop:"+width+"px;"*/
+"center:yes;"
+"edge:raised;" // sunken | raised
+"resizable:no;"
+"status:no;"
+"scroll:no;";
var returnValue = window.showModalDialog("formA1_tab1_Bro2.php","", diaxFeature);
//alert("value is : "+returnValue);
var myStr=new Array();
myStr = returnValue.split("-");
document.getElementById("txtEmp").value = myStr[0];
document.getElementById("txtEmp1").value = myStr[1];
}
function onCancel(){
window.location='';
}
function onBack(){
window.location='formA1.php';
}
function IsCheck(txtName, txtOther, txtSize, txtSize1, txtPage, txt1, txt2, txt3, txt4, txt5, txtComment)
{
//alert(eText);
if(document.getElementById(txtName).value == ''
&& document.getElementById(txtOther).value == ''
&& document.getElementById(txtSize).value == ''
&& document.getElementById(txtSize1).value == ''
&& document.getElementById(txtPage).value == ''
&& document.getElementById(txt1).value == ''
&& document.getElementById(txt2).value == ''
&& document.getElementById(txt3).value == ''
&& document.getElementById(txt4).value == ''
&& document.getElementById(txt5).value == ''
&& document.getElementById(txtComment).value == ''
)
{
alert('กรุณาใส่ข้อมูล');
return false;
}
else if(document.getElementById(txtName).value == ''
|| document.getElementById(txtOther).value == ''
|| document.getElementById(txtSize).value == ''
|| document.getElementById(txtSize1).value == ''
|| document.getElementById(txtPage).value == ''
|| document.getElementById(txt1).value == ''
|| document.getElementById(txt2).value == ''
|| document.getElementById(txt3).value == ''
|| document.getElementById(txt4).value == ''
|| document.getElementById(txt5).value == ''
|| document.getElementById(txtComment).value == ''
)
{
alert('กรุณาใส่ข้อมูลให้ครบ');
return false;
}
var txtPhoneFilter=/^([0-9]){1,}$/;
var txtPhone=document.form1.txtPhone.value;
if (!(txtPhoneFilter.test(txtPhone)))
{
alert ("เบอร์โทรศัพท์ต้องป็นตัวเลข");
return false;
}
var txtFaxFilter=/^([0-9]){1,}$/;
var txtFax=document.form1.txtFax.value;
if (!(txtFaxFilter.test(txtFax)))
{
alert ("เบอร์โทรสารต้องป็นตัวเลข");
return false;
}
var txtCreditFilter=/^([0-9]){1,}$/;
var txtCredit=document.form1.txtCredit.value;
if (!(txtCreditFilter.test(txtCredit)))
{
alert ("ปล่อยเครดิตต้องป็นตัวเลข");
return false;
}
var txtEmailFilter=/^.+@.+\..{2,3}$/;
var txtEmail=document.form1.txtEmail.value;
if (!(txtEmailFilter.test(txtEmail)))
{
alert ("อีเมล์ไม่ถูกต้อง");
return false;
}
else
return true;
}
</script>
</head>
<body>
<form id="frmMain">
<span id="mySpan"></span>
<table width="100%" height="100%" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#0000FF">
<!--DWLayoutTable-->
<tr>
<td valign="top">
<table width="100%" border="1" align="center" bordercolor="#0099FF" bgcolor="#CCFFFF">
<tr>
<td width="128"><div align="right">เลขที่งาน :</div></td>
<td width="153"><div align="left">
<label>
<?=$LastID?>
<input type="hidden" name="txtCode" id="txtCode" disabled="disabled" value="<?=$LastID?>" />
</label>
</div></td>
<td width="142" colspan="3"><div align="right">วันที่ปรับปรุง :</div></td>
<td width="267"><div align="left">
<label>
<?=$CalDate?>
<input type="hidden" name="txtDate" id="txtDate" disabled="disabled" value="<?=$CalDate?>" />
</label>
</div></td>
</tr>
<tr>
<td><div align="right">ชื่องาน :</div></td>
<td colspan="5"><div align="left">
<label>
<input name="txtName" id="txtName" type="text" size="100" value="<?=$JobName?>" />
</label>
</div></td>
</tr>
<tr>
<td><div align="right">ลักษณะงาน :</div></td>
<td colspan="5"><div align="left">
<?php
echo "<label>";
$table_field1 = "JobTypeNo";
$table_field2 = "JobTypeName";
$strSQL= "SELECT JobTypeNo, JobTypeName FROM TBJobType";
$objConnect = mysql_connect($host,$user,$pass) or die("Error Connect to Database");
$objDB = mysql_select_db($db);
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
echo "<select name=\"SelWork\" id=\"SelWork\">";
while($row = mysql_fetch_array($objQuery))
{
?>
<option value="<?=$row[$table_field1]?>" <? if($JobType != '' && $row[$table_field1] == $JobType){ echo "selected=\"selected\"";}?>><?=$row[$table_field2]?></option>
<?
}
echo "</select>";
echo "</label>";
?>
ระบุ
<label>
<input type="text" name="txtOther" id="txtOther" value="<?=$OthJobType?>" />
</label>
</div></td>
</tr>
<tr>
<td><div align="right">ขนาด (กxย) :</div></td>
<td colspan="5"><div align="left">
<label>
<input type="text" name="txtSize" id="txtSize" value="<?=$PrdSizeW?>" />
</label>
x
<label>
<input type="text" name="txtSize1" id="txtSize1" value="<?=$PrdSizeH?>" />
</label>
<label>
<select name="SelSize" id="SelSize">
<option value="1" <? if($SizeID != '' && $SizeID == 1){ echo "selected=\"selected\"";}?>>นิ้ว</option>
<option value="2" <? if($SizeID != '' && $SizeID == 2){ echo "selected=\"selected\"";}?>>ซ.ม.</option>
</select>
</label>
</div></td>
</tr>
<tr>
<td><div align="right">จำนวน :</div></td>
<td><div align="left">
<label>
<input name="txtPage" id="txtPage" type="text" size="10" value="<?=$QtyPage?>" />
</label>
หน้า
</div></td>
<td width="142"><div align="right">เข้าเล่ม :</div></td>
<td colspan="3"><div align="left">
<?php
echo "<label>";
require_once('connect.php');
$objConnect = mysql_connect($host,$user,$pass) or die("Error Connect to Database");
$objDB = mysql_select_db($db);
$table_field1 = "BindNo";
$table_field2 = "BindName";
$strSQL= "SELECT BindNo, BindName FROM TBBindType";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
echo "<select name=\"SelBook\" id=\"SelBook\">";
while($row = mysql_fetch_array($objQuery))
{
?>
<option value="<?=$row[$table_field1]?>" <? if($BindType != '' && $row[$table_field1] == $BindType){ echo "selected=\"selected\"";}?>><?=$row[$table_field2]?></option>
<?
}
echo "</select>";
echo "</label>";
?>
</div></td>
</tr>
<tr>
<td><div align="right">ยอดพิมพ์ 1 :</div></td>
<td colspan="5"><div align="left">
<label>
<input type="text" name="txt1" id="txt1" value="<?=$QtyPrn1?>" />
</label>
<select name="unit1" id="unit1">
<option value="1">ใบพิมพ์</option>
<option value="2">ใบเล็ก</option>
<option value="5">ใบ</option>
<option value="3">เล่ม</option>
<option value="4">หน่วย</option>
</select>
</div></td>
</tr>
<tr>
<td><div align="right">2 :</div></td>
<td colspan="5"><div align="left">
<label>
<input type="text" name="txt2" id="txt2" value="<?=$QtyPrn2?>" />
</label>
<select name="unit2" id="unit2">
<option value="1">ใบพิมพ์</option>
<option value="2">ใบเล็ก</option>
<option value="5">ใบ</option>
<option value="3">เล่ม</option>
<option value="4">หน่วย</option>
</select>
</div></td>
</tr>
<tr>
<td><div align="right">3 :</div></td>
<td colspan="5"><div align="left">
<label>
<input type="text" name="txt3" id="txt3" value="<?=$QtyPrn3?>" />
</label>
<select name="unit3" id="unit3">
<option value="1">ใบพิมพ์</option>
<option value="2">ใบเล็ก</option>
<option value="5">ใบ</option>
<option value="3">เล่ม</option>
<option value="4">หน่วย</option>
</select>
</div></td>
</tr>
<tr>
<td><div align="right">4 :</div></td>
<td colspan="5"><div align="left">
<label>
<input type="text" name="txt4" id="txt4" value="<?=$QtyPrn4?>" />
</label>
<select name="unit4" id="unit4">
<option value="1">ใบพิมพ์</option>
<option value="2">ใบเล็ก</option>
<option value="5">ใบ</option>
<option value="3">เล่ม</option>
<option value="4">หน่วย</option>
</select>
</div></td>
</tr>
<tr>
<td><div align="right">5 :</div></td>
<td colspan="5"><div align="left">
<label>
<input type="text" name="txt5" id="txt5" value="<?=$QtyPrn5?>" />
</label>
<select name="unit5" id="unit5">
<option value="1">ใบพิมพ์</option>
<option value="2">ใบเล็ก</option>
<option value="5">ใบ</option>
<option value="3">เล่ม</option>
<option value="4">หน่วย</option>
</select>
</div></td>
</tr>
<tr>
<td><div align="right">หมายเหตุ :</div></td>
<td colspan="5"><div align="left">
<label>
<input name="txtComment" id="txtComment" type="text" size="100" value="<?=$JobRemark?>" />
</label>
<label></label>
</div></td>
</tr>
<tr>
<td><div align="right">ลูกค้า:</div></td>
<td colspan="5"><div align="left">
<label>
<input type="text" name="txtCus" readonly="readonly" id="txtCus" value="<?=$CustID?>" />
<?
if($CustID != ''){
$strSQL = "SELECT company FROM TBcustomer WHERE CustID='$CustID'";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$objResult = mysql_fetch_array($objQuery);
$company=$objResult['company'];
}
?>
<input name="txtCus1" id="txtCus1" readonly="readonly" type="text" size="80" value="<?=$company?>" />
</label>
<label></label>
<label>
<input type="button" name="btnCus" value="Browes" style="width:100px" onclick="javascript:MM_openBrWindow('formA1_tab1_Bro1.php','pop','scrollbars=yes,width=1100,height=300')"/>
</label>
</div></td>
</tr>
<tr>
<td><div align="right">พนักงานขาย :</div></td>
<td colspan="5"><div align="left">
<label>
<input type="text" name="txtEmp" id="txtEmp" readonly="readonly" value="<?=$SaleID?>" />
<?
if($SaleID != ''){
$strSQL = "SELECT FLName FROM TBsaleman WHERE SalemanID='$SaleID'";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$objResult = mysql_fetch_array($objQuery);
$FLName=$objResult['FLName'];
}
?>
<input name="txtEmp1" id="txtEmp1" readonly="readonly" type="text" size="80" value="<?=$FLName?>" />
</label>
<label></label>
<input type="button" name="btnEmp" value="Browes" style="width:100px" onclick="javascript:searchResultSaleman('formA1_tab1_Bro2.php','pop','scrollbars=yes,width=1100,height=300')"/>
</div></td>
</tr>
<tr>
<td colspan="6"><div align="center">
<input type="hidden" name="status" id="status" value="<?=$status?>" />
<input type="button" name="btnAdd" value="ตกลง" style="width:100px" onclick="JavaScript:doCallAjax();"/>
<!-- <input type="button" name="btnCancel" value="ยกเลิก" style="width:100px" onclick="JavaScript:onCancel();"/> -->
<input type="button" name="btnBack" value="กลับไปหน้าหลัก" style="width:100px" onclick="JavaScript:onBack();"/>
</div></td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>
Tag : PHP
|
ประวัติการแก้ไข 2011-11-21 21:00:56
|
|
|
|
|
Date :
2011-11-21 20:58:15 |
By :
tangsupap |
View :
1103 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ลองกำหนดที่ฟอร์มดูนะ <form id="frmMain" onsubmit="return IsCheck()">
|
|
|
|
|
Date :
2011-11-21 21:46:30 |
By :
ozma |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<form id="frmMain" onsubmit="return IsCheck('txtName','txtOther','txtSize','txtSize1','txtPage','txt1','txt2','txt3','txt4','txt5','txtComment')">
ยังไม่ได้ เลยอะครับ
|
ประวัติการแก้ไข 2011-11-21 22:51:18
|
|
|
|
Date :
2011-11-21 22:47:02 |
By :
tangsupap |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|