Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,030

HOME > PHP > PHP Forum > ช่วยแก้ไขโค้ดให้ด้วยค่ะ(ด่วนๆๆๆๆ) คือว่าอยากให้มันแสดง alert ขึ้นมาเวลาเราใส่ค่าในช่อง print



 

ช่วยแก้ไขโค้ดให้ด้วยค่ะ(ด่วนๆๆๆๆ) คือว่าอยากให้มันแสดง alert ขึ้นมาเวลาเราใส่ค่าในช่อง print

 



Topic : 019568

Guest




คือว่าอยากให้มันแสดง alert ขึ้นมาเวลาเราใส่ค่าในช่อง
print "<td><input style=\"text-align: center\" type=text name=discount[] id discount$inum size=1 maxlength=2 onkeypress=return check_dis('discount$inum'); value=$discount>% ";
นี้เกิน 50 อ่ะคะ
ตรงนี้จะเป็นโค้ดที่เขียนเช็คค่า
<SCRIPT language=JavaScript>
function check_dis(val) {
alert(val);
var x = document.getElementById(val).value;
if(x>50){
alert('ส่วนลดต้องไม่เกิน 50%');

return false;
}
return true;
}
</script>

ตรงนี้จะเป็นโค้ดทั้งหมด
<?
session_start();
include("config.php");
$script_url = $_SERVER["PHP_SELF"];

if($_GET[action]=="clear"){
$sql = "delete from tbl_fans_item where ip='$ip' ";
$res=mysql_query($sql) or die(mysql_error() . mysql_errno());
if($res){
header("Location: -quotation-step1.php");
exit();
}
exit();
}

if($_GET[action]=="add"){
$fan_id=$_GET[fan_id];
$cus_id=$_GET[cus_id];
$pro_id=$_GET[pro_id];
# $result=mysql_query("select FAN_ID from tbl_fans_item where FAN_ID='$fan_id' ");
# if($rs=mysql_fetch_array($result)){
# $query=mysql_query("update tbl_fans_item set FAN_NUM=FAN_NUM+1 where FAN_ID='$rs[FAN_ID]' ");
# header("Location: ".$PHP_SELF."?action=view");
# exit();
# }else{
$res=select("fans", " where FAN_ID='$fan_id' ");
$rs=fetch($res);

$query=mysql_query("insert into tbl_fans_item values('', '$cus_id', '$pro_id', '$fan_id', '$rs[CFM]', '$rs[INWG]', '$rs[RPM]', '$rs[KW]', '$rs[PH]', '1', '', '', '$ip')");
if($query){
header("Location: ".$PHP_SELF."?action=view");
exit();
}
# }
exit();
}

if($_GET[action]=="update"){
if(isset($_GET[Submit])){
for($i=0; $i<count($_GET[fan_id]); $i++){
$res=mysql_query(" update tbl_fans_item set cus_id='".$_GET[cus_id]."', pro_id='".$_GET[pro_id]."', FAN_CFM='".$_GET[cfm][$i]."', FAN_INWG='".$_GET[inwg][$i]."', FAN_RPM='".$_GET[rpm][$i]."', FAN_KW='".$_GET[kw][$i]."', FAN_NUM='".$_GET[num][$i]."', FAN_DIS='".$_GET[discount][$i]."', command='".$_GET[com][$i]."' where id='".$_GET[id][$i]."' and FAN_ID='".$_GET[fan_id][$i]."' and ip='$ip' ");
}
if($res){
header("Location: ".$PHP_SELF."?action=view");
exit();
}
}

if(isset($_GET[Submit_drop])){
for($i=0; $i<count($_GET[fan_id_drop]); $i++){
$res=mysql_query(" delete from tbl_fans_item where id='".$_GET[id][$i]."' and FAN_ID='".$_GET[fan_id_drop][$i]."' and ip='".$_GET[ip]."' ");

#$res=mysql_query(" delete from tbl_fans_item where id='".$_GET[id][$i]."' and FAN_ID='".$_GET[fan_id_drop][$i]."' ");
#print $_GET[fan_id_drop][$i]." id: ".$_GET[id][$i]."<br>";
}

if($res){
header("Location: ".$PHP_SELF."?action=view");
}else{
header("Location: ".$PHP_SELF."?action=view");
}
exit();
}

exit();
}

if($_GET[action]=="drop"){
$fan_id=$_GET[fan_id];
$id=$_GET[id];
$res=mysql_query(" delete from tbl_fans_item where id='$id' and FAN_ID='$fan_id' ");
if($res){
header("Location: ".$PHP_SELF."?action=view");
exit();
}
exit();
}


if($_GET[action]=="view"){
view($ip);
}

function view($ip){

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
<link href="style.css" rel="stylesheet" type="text/css">

</style>
<SCRIPT language=JavaScript>
function check_number() {
e_k=event.keyCode
//if (((e_k < 48) || (e_k > 57)) && e_k != 46 ) {
if (e_k != 13 && (e_k < 48) || (e_k > 57)) {
event.returnValue = false;
alert("คุณต้องใส่เป็นตัวเลขท่านั้น");
}
}
</script>

<SCRIPT language=JavaScript>
function check_dis(val) {
alert(val);
var x = document.getElementById(val).value;
if(x>50){
alert('ส่วนลดต้องไม่เกิน 50%');

return false;
}
return true;
}
</script>


</head>

<body >
<br>
<div class="title" align = "center"> <a href="<?=$thispage?>?action=view">เสนอราคา</a> </div>
<?
$res=mysql_query("select * from tbl_fans_item where ip='$ip' order by id ");
$cus=fetch(select("tbl_fans_item", " where cus_id!='' and ip='$ip' "));
$port_cus=fetch(select("customer", " where CUSTOMER_ID='$cus[cus_id]' "));
$pro=fetch(select("tbl_fans_item", " where pro_id!='' and ip='$ip' "));
?>
<form action="<?=$_SERVER['PHP_SELF']?>" method="get" name="form1" enctype="multipart/form-data">
<input type=hidden name="ip" value="<?=$ip?>">
<strong> <font color = "#000099"> ข้อมูลลูกค้า</strong> </font>
<table width="100%" border="0" cellpadding="4" cellspacing="0" bgcolor="f7f7f3">
<tr>
<td width="100" align="right"> <strong> <font color = "#000099">รหัสลูกค้า </strong> </font> </td>
<td width="100" align="center"><input type="hidden" name="cus_id" value="<?=$cus[cus_id]?>"><?=$cus[cus_id]?></td>
<td>
<b><?=cus_name($cus[cus_id])?></b> <strong> <font color = "#000099">
[ ผู้ติดต่อ. </strong> </font>
<?=$port_cus[CUSTOMER_NE]?> <strong> <font color = "#000099">
โทรศัพท์ : </font> </strong>
<?=$port_cus[TEL]?> <strong> <font color = "#000099">
โทรสาร : </font> </strong>
<?=$port_cus[FAX]?> <strong> <font color = "#000099">
] </font> </strong> </td>
</tr>
<tr>
<td align="right"> <strong> <font color = "#000099"> รหัสโครงการ </font> </strong> </td>
<td align="center"><input name="pro_id" type="hidden" value="<?=$pro[pro_id]?>"><?=$pro[pro_id]?></td>
<td><?=pro_name($pro[pro_id])?></td>
</tr>
</table>
<BR>
<strong> <font color = "#000099"> รายการเสนอราคา </FONT> </strong>
<table width="100%" border="2" cellpadding="3" cellspacing="0" bordercolor="f5f5f5">
<tr bgcolor="#FF9999">

<td> <strong> <center> <font color = "#000099" size = "2"> รายการที่</strong> </font> </center></td>
<td><strong> <center> <font color = "#000099" size = "2"> อ้างอิง</strong> </font> </center></td>
<td><strong> <center> <font color = "#000099" size = "2">รหัสสินค้า</strong> </font> </center></td>
<td><strong> <center> <font color = "#000099" size = "2">รหัสประเภทสินค้า</strong> </font> </center></td>
<td><strong> <center> <font color = "#000099" size = "2">ชื่อสินค้า</strong> </font> </center></td>
<td><strong> <center> <font color = "#000099" size = "2">ปริมาณลม (CFM.)</strong> </font> </center></td>
<td><strong> <center> <font color = "#000099" size = "2">ระบบท่อ (IN.WG)</strong> </font> </center></td>
<td><strong> <center> <font color = "#000099" size = "2">รอบพัดลม (RPM.)</strong> </font> </center></td>
<td><strong> <center> <font color = "#000099" size = "2">กิโลวัตต์ (KW.)</strong> </font> </center></td>
<td><strong> <center> <font color = "#000099" size = "2">ระบบไฟฟ้า (V/PH/Hz)</strong> </font> </center></td>
<td><strong> <center> <font color = "#000099" size = "2">ราคาขาย</strong> </font> </center></td>
<td><strong> <center> <font color = "#000099" size = "2">จำนวน</strong> </font> </center></td>
<td><strong> <center> <font color = "#000099" size = "2">ส่วนลด</strong> </font> </center></td>
<td><strong> <center> <font color = "#000099" size = "2">ราคาหลังหักส่วนลด</strong> </font> </center></td>
<td><strong> <center> <font color = "#000099" size = "2">ราคารวม</strong> </font> </center></td>
<td><strong> <center> <font color = "#000099" size = "2">ลบ</strong> </font> </center></td>
</tr>
<?
$inum=1;
while($row=mysql_fetch_array($res)){

if($row[FAN_ID]){
$button='<input type="submit" name="Submit" value="ปรับปรุง" style="background: url() left no-repeat; padding-left: 10px; border: 0px; color: #0000FF">';
$button_drop='<input type="submit" name="Submit_drop" value="ลบ" style="padding-left: 5px; padding-right: 5px; border: 0px; color: #0000FF">';
$save='<a href="-quotation-step3.php?action=view">บันทึก &raquo;</a>';
$clear='<a href="-quotation-step2.php?action=clear" onClick="return confirm(\'คุณต้องการยกเลิกรายการทั้งหมดใช่หรือไม่ ?\')"><font color=red>[ ยกเลิก ]</font></a>';
$error='';
}else{
$button='<input type="button" name="Submit" value="ปรับปรุง" style="background: url() left no-repeat; padding-left: 10px; border: 0px; color: #666666">';
$button_drop='<input type="button" name="Submit_drop" value="ลบ" style="padding-left: 5px; padding-right: 5px; border: 0px; color: #666666">';
$save='บันทึก &raquo;';
$clear='<a href="-quotation-step2.php?action=clear" onClick="return confirm(\'คุณต้องการยกเลิกรายการทั้งหมดใช่หรือไม่ ?\')"><font color=red>[ ยกเลิก ]</font></a>';
$error='<font color=red>ยังไม่มีรายการสินค้า กรุณาเลือกสินค้า</font><br>';
}

$result=mysql_query(" select * from fans where FAN_ID='$row[FAN_ID]' ")or die(mysql_error() . mysql_errno());
$rs=mysql_fetch_array($result);

if($rs){
$color=($color=="#FFE4E1") ? "#EED5D2" : "#FFE4E1";
$i++;
print "<tr valign=top bgcolor=\"$color\" onmouseover=\"this.bgColor='#CDB7B5' \" onmouseout=\"this.bgColor='$color' \">";
print "<tr bgcolor=$color>";
print "<input type=hidden name=action value=update>";
print "<input type=hidden name=\"id[]\" value=\"$row[id]\">";
print "<input type=hidden name=fan_id[] value=$rs[FAN_ID]>";

#print "<input type=\"checkbox\" name=\"fan_id_drop[]\" value=\"$rs[FAN_ID]\" id=\"$rs[FAN_ID]\">";

print "<td align = center> $i";
print "<td><input type=text name=\"com[]\" value=\"$row[command]\" size=\"10\">";
print "<td>$rs[FAN_ID]";
print "<td>$rs[type_id]";
print "<td>$rs[MODEL_FAN]";
if($row[FAN_CFM]!=""){ $cfm=$row[FAN_CFM]; } else { $cfm=$rs[CFM]; }
print "<td><input type=text name=cfm[] size=6 maxlength=10 value=$cfm>";
if($row[FAN_INWG]!=""){ $inwg=$row[FAN_INWG]; } else { $inwg=$rs[INWG]; }
print "<td><input type=text name=inwg[] size=6 maxlength=10 value=$inwg>";
if($row[FAN_RPM]!=""){ $rpm=$row[FAN_RPM]; } else { $rpm=$rs[RPM]; }
print "<td><input type=text name=rpm[] size=6 maxlength=10 value=$rpm>";
if($row[FAN_KW]!=""){ $kw=$row[FAN_KW]; } else { $kw=$rs[KW]; }
print "<td><input type=text name=kw[] size=6 maxlength=10 value=\"$kw\">";
print "<td align = center>$rs[PH]";
print "<td align=right>".number_format($rs[PRICE], 2, '.', ',');
print "<td> <input type=text style=\"text-align: center\" name=num[] value=$row[FAN_NUM] size=1 maxlength=10 onkeypress=check_number();>";
if(!$row[FAN_DIS]){
$discount=20;

}else{
$discount=$row[FAN_DIS];
}

$per=($rs[PRICE]*$row[FAN_NUM])*$discount/100;
$price=($rs[PRICE]*$row[FAN_NUM])-$per;
print "<td><input style=\"text-align: center\" type=text name=discount[] id discount$inum size=1 maxlength=2 onkeypress=return check_dis('discount$inum'); value=$discount>% ";
print "<td align=right>";
print number_format($per, 2, '.', ',');
print "<td align=right>";
print number_format($price, 2, '.', ',');
print "<td align=right>";
print "<a href=\"$PHP_SELF?action=drop&fan_id=$rs[FAN_ID]&id=$row[id]\" onClick=\"return confirm('คุณต้องการลบรายการที่ $i ใช่หรือไม่ ?\ ')\"><img src=images/b_drop.png border=0></a>";

}
$total_price+=$price;
$inum++;
}

?>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td colspan="10" align="right"> <strong> <font color = "#000099"> ราคารวม </font> </strong> </td>
<td align="right" bgcolor="#FFFFCC">
<?=number_format($total_price, 2, '.', ',')?>
</td>

</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td colspan="10" align="right"> <strong> <font color = "#000099"> ภาษีมูลค่าเพิ่ม 7% </font> </td>
<td align="right" bgcolor="#CCFFFF">
<?
$tax=$total_price*0.07;
print number_format($tax, 2, '.', ',');
?>
</td>

<td></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td colspan="10" align="right"> <strong> <font color = "#000099"> ราคารวมทั้งหมด </font> </td>
<td align="right" bgcolor="#FFCCFF">
<?
$payment=$total_price+$tax;
print number_format($payment, 2, '.', ',');
?>
</td>

</tr>
<tr>
<td colspan="11"> <a href="-fans.php">&laquo;เลือกสินค้า</a> |
<?=$button?>
<!-- |
<?=$button_drop?>
-->
|
<?=$save?>
</td>
</tr>
</table> <br>
<?=$error?><font color="#666666"size = "3">*ทุกครั้งที่มีการเพิ่ม/แก้ไขรายการสินค้าและข้อมูลอื่นๆ กรุณาคลิกปรับปรุงก่อนบันทึกทุกรั้ง </font>
<?=$clear?>
</form>
</body>
</html>
<?
}
?>


Tag : - - - -







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 20 เม.ย. 2551 11:37:40 By : เด็กโง่ View : 1480 Reply : 0
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : ช่วยแก้ไขโค้ดให้ด้วยค่ะ(ด่วนๆๆๆๆ) คือว่าอยากให้มันแสดง alert ขึ้นมาเวลาเราใส่ค่าในช่อง print
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 01
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่