|
|
|
รบกวนพี่ๆช่วยหน่อยครับ พอดีว่าผมจะทำช่อง sum auto textbox สองช่องแต่ว่า script ไม่ทำงานครับ |
|
|
|
|
|
|
|
ตามหัวข้อเลยครับ
กรอบสี่เหลี่ยมสีแดงในภาพคือช่อง textbox ที่ต้องการจะทำ auto sum ครับ
โค้ด insert.php
<?php require_once('Connections/Connect.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "insert_pro")) {
$insertSQL = sprintf("INSERT INTO production (Pro_user_id, Pro_name, Pro_department, Pro_in, Pro_out, Pro_hour, Pro_shift, Pro_detail, Working_day) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['Pro_user_id'], "int"),
GetSQLValueString($_POST['Pro_name'], "text"),
GetSQLValueString($_POST['Pro_department'], "text"),
GetSQLValueString($_POST['Pro_in'], "int"),
GetSQLValueString($_POST['Pro_out'], "int"),
GetSQLValueString($_POST['Pro_hour'], "int"),
GetSQLValueString($_POST['Pro_shift'], "text"),
GetSQLValueString($_POST['Pro_detail'], "text"),
GetSQLValueString($_POST['Working_day'], "date"));
mysql_select_db($database_Connect, $Connect);
$Result1 = mysql_query($insertSQL, $Connect) or die(mysql_error());
}
mysql_select_db($database_Connect, $Connect);
$query_P = "SELECT * FROM production";
$P = mysql_query($query_P, $Connect) or die(mysql_error());
$row_P = mysql_fetch_assoc($P);
$totalRows_P = mysql_num_rows($P);
?>
<!DOCTYPE html>
<!-- saved from url=(0043)http://getbootstrap.com/examples/offcanvas/ -->
<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="http://getbootstrap.com/favicon.ico">
<link href="./css/bootstrap.min.css" rel="stylesheet">
<link href="./css/bootstrap.css.map" rel="stylesheet">
<link href="./css/bootstrap-theme.css" rel="stylesheet">
<link href="./css/bootstrap-theme.min.css" rel="stylesheet">
</head>
<body>
<style type="text/css">
.center_div {
margin:auto;
width:90%;
background-color:#;
}
</style>
<script language="javascript">
function sumP()
{
var Pro_in = document.insert_pro.Pro_in.value;
var Pro_out = document.insert_pro.Pro_out.value;
document.insert_pro.Pro_hour.value = Pro_out-Pro_in
}
</script>
<div class="center_div">
<div class="contrainer">
<div class="row">
<div class="col-lg-10">
<h3 class="alert btn-primary"><i class=""></i> เพิ่มข้อมูลการทำงานล่วงเวลา</h3>
</div>
<!-- /.col-lg-12 -->
</div>
</div>
<form action="<?php echo $editFormAction; ?>" role="form" name="insert_pro" id="insert_pro" class="form-group" method="POST">
<div class="row">
<div class="col-lg-10">
<div class="panel panel-default">
<div class="panel-body">
<div class="row">
<div class="col-lg-12">
<div class="col-lg-4">
<div class="form-group">
<label>จากเวลา</label>
<select type="text" name="Pro_in" class="form-control" value="" onkeyup="sumP()" placeholder="*** ระบุ" /> <option></option>
<option>6.00</option>
<option>18.00</option>
</select>
</div></div>
<div class="col-lg-4">
<div class="form-group">
<label>ถึงเวลา</label>
<select type="text" name="Pro_out" class="form-control" value="" onkeyup="sumP()" placeholder="*** ระบุ" /> <option></option>
<option>7.00</option>
<option>8.00</option>
<option>19.00</option>
<option>20.00</option>
</select>
</div></div>
<div class="col-lg-4">
<div class="form-group">
<label> จำนวนชั่วโมง</label>
<input type="text" name="Pro_hour" class="form-control input-sm" placeholder="*** ระบุ" />
</div></div></div>
<div class="row">
<div class="col-lg-4">
<div class="form-group">
<label>กะทำงาน</label>
<select name="Pro_shift" class="form-control" id="Pro_shift" required="*** ระบุ"/> <option></option>
<option>Day</option>
<option>Night</option>
</select>
</div></div>
<div class="col-lg-4">
<div class="form-group">
<label> รายละเอียดงาน</label>
<textarea name="Pro_detail" class="form-control" id="Pro_detail" placeholder="ระบุรายละเอียดงานถ้าไม่มีใส่เครื่องหมาย -" required/></textarea>
</div></div>
<div class="row">
<div class="col-lg-12">
<div class="form-group">
<li class="btn-danger divider" style="height:3px;"></li>
</div></div>
</div>
<div class="col-lg-4">
<div class="form-group">
<button type="submit" class="btn btn-success" id="btnConfirm" >บันทึกข้อมูล</button>
<button type="reset" class="btn btn-default">เริ่มใหม่</button>
</div></div>
</div>
</div>
</div></div></div>
<input type="hidden" name="MM_insert" value="insert_pro">
</form>
</div>
</body>
</html>
<?php
mysql_free_result($P);
?>
อัพเดทตอนนี้ใช้งานได้แล้วครับ
Tag : PHP, MySQL
|
ประวัติการแก้ไข 2017-12-09 18:17:08 2017-12-11 11:39:34
|
|
|
|
|
Date :
2017-12-09 18:01:45 |
By :
Lun2560 |
View :
936 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JavaScript DateDiff() Calculating the difference date time
|
|
|
|
|
Date :
2017-12-14 11:51:30 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|