|
|
|
มีปัญหาในการทำ dependantlistmenu เมื่อนำมาใส่รวมกับตัวทำงานอื่นๆ |
|
|
|
|
|
|
|
ผมมีปัญหาในการทำ dependantlistmenu ครับ
โดยผมได้ทำการแก้ไฟล์ dependantlistmenu.php
จาก https://www.thaicreate.com/community/dependant-listmenu-dropdownlist.html
และทำการลดสอบได้ผลตรงตามปกติ
และผมเลยนำ สคริปที่ทำใน dependantlistmenu.php ไปใส่ไว้ใน
กลางหน้าเว็บ ของ add_book.php
ทำให้เกิดปัญหาดังกล่างขึ้น
มันไม่สามารถแสดงLISTBOX ที่ 2 ขึ้นมาแสดงได้ครับ
พี่ท่านใดพอทราบทางแก้ แนะนำหน่อยครับ
โค๊สต้นฉบับ
Code (PHP)
<?php
/*** By Weerachai Nukitram ***/
/*** http://www.ThaiCreate.Com ***/
$objConnect3 = mysql_connect("localhost","library","compaq") or die("Error Connect to Database");
$objDB2 = mysql_select_db("library");
@mysql_query("SET NAMES UTF8");
?>
<script language = "JavaScript">
//**** List Province (Start) ***//
function ListProvince(SelectValue)
{
frmMain.ddlProvince.length = 0
//frmMain.ddlAmphur.length = 0
//*** Insert null Default Value ***//
var myOption = new Option('','')
frmMain.ddlProvince.options[frmMain.ddlProvince.length]= myOption
<?
$intRows = 0;
$strSQL7 = "SELECT * FROM book_sub_group";
$objQuery7 = mysql_query($strSQL7) or die ("Error Query [".$strSQL7."]");
$intRows = 0;
while($objResult7 = mysql_fetch_array($objQuery7))
{
$intRows++;
?>
x = <?=$intRows;?>;
mySubList = new Array();
strGroup = <?=$objResult7["book_group_id"];?>;
strValue = "<?=$objResult7["book_sub_group_id"];?>";
strItem = "<?=$objResult7["book_sub_group_name"];?>";
mySubList[x,0] = strItem;
mySubList[x,1] = strGroup;
mySubList[x,2] = strValue;
if (mySubList[x,1] == SelectValue){
var myOption = new Option(mySubList[x,0], mySubList[x,2])
frmMain.ddlProvince.options[frmMain.ddlProvince.length]= myOption
}
<?
}
?>
}
//**** List Province (End) ***//
function MM_goToURL() { //v3.0
var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
</script>
</head>
<form name="frmMain" method="POST">
Geography
<select id="ddlGeo" name="ddlGeo" onChange = "ListProvince(this.value)">
<option selected value=""></option>
<?
$strSQL8 = "SELECT * FROM book_group ";
$objQuery8 = mysql_query($strSQL8) or die ("Error Query [".$strSQL8."]");
while($objResult8 = mysql_fetch_array($objQuery8))
{
?>
<option value="<?=$objResult8["book_group_id"];?>"><?=$objResult8["book_groyp_name"];?></option>
<?
}
?>
</select>
Province
<select id="ddlProvince" name="ddlProvince" style="width:120px" onChange = "ListAmphur(this.value)"></select>
<? //Amphur <select id="ddlAmphur" name="ddlAmphur" style="width:200px"></select> ?>
<label>
</label>
<label>
</label>
</form>
<?
mysql_close($objConnect3);
?>
โค๊ต หน้าที่มีปัญหาครับ
Code (PHP)
<?php require_once('Connections/library.php'); ?>
<?php require_once('Connections/library.php'); ?>
<?php require_once('Connections/library.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$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"] == "form1")) {
$insertSQL = sprintf("INSERT INTO book (book_isbn, book_name, book_author, book_booktype, book_press, book_page, book_timeprint, book_detail) VALUES (%s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['txtUsername'], "text"),//ISBN
GetSQLValueString($_POST['book_name'], "text"),
GetSQLValueString($_POST['book_author'], "text"),
GetSQLValueString($_POST['book_booktype'], "int"),
GetSQLValueString($_POST['book_press'], "int"),
GetSQLValueString($_POST['book_page'], "int"),
GetSQLValueString($_POST['book_timeprint'], "int"),
GetSQLValueString($_POST['book_detail'], "text"));
mysql_select_db($database_library, $library);
$Result1 = mysql_query($insertSQL, $library) or die(mysql_error());
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO book_number (book_isbn, book_number_number, book_copy) VALUES (%s, %s, %s)",
GetSQLValueString($_POST['txtUsername'], "text"),//ISBN
GetSQLValueString($_POST['book_number_number'], "text"),
GetSQLValueString($_POST['book_coppy'], "text"));
mysql_select_db($database_library, $library);
$Result1 = mysql_query($insertSQL, $library) or die(mysql_error());
}
?>
<?
//upload image 1
for($i=0;$i<count($_FILES["fileUpload"]["name"]);$i++)
{
if(trim($_FILES["fileUpload"]["tmp_name"][$i]) != "")
{
$images = $_FILES["fileUpload"]["tmp_name"][$i];
$new_images = $_FILES["fileUpload"]["name"][$i];
copy($_FILES["fileUpload"]["tmp_name"][$i],"MyResize/$txtUsername"."_1_".$_FILES["fileUpload"]["name"][$i]);
$width=640; //*** Fix Width & Heigh (Autu caculate) ***//
$size=GetimageSize($images);
$height=round($width*$size[1]/$size[0]);
$images_orig = ImageCreateFromJPEG($images);
$photoX = ImagesX($images_orig);
$photoY = ImagesY($images_orig);
$images_fin = ImageCreateTrueColor($width, $height);
ImageCopyResampled($images_fin, $images_orig, 0, 0, 0, 0, $width+1, $height+1, $photoX, $photoY);
ImageJPEG($images_fin,"MyResize/$txtUsername".$new_images);
ImageDestroy($images_orig);
ImageDestroy($images_fin);
//User Make No Echo
//echo "Resize Successful.<br>";
//*** Insert Record ***//
$objConnect = mysql_connect("localhost","library","compaq") or die("Error Connect to Database");
$objDB = mysql_select_db("library");
$strSQL = "INSERT INTO book_image";
$strSQL .="(image_path,book_isbn,image_type) VALUES
('"."MyResize/".$_POST['txtUsername']."_1_".$_FILES["fileUpload"]["name"][$i]."','".$_POST['txtUsername']."','1')";
//('".$new_images."','".$_FILES["fileUpload"]["name"][$i]."','".$_POST['txtUsername']."')";
$objQuery = mysql_query($strSQL) or die(mysql_error());
}
}
//end upload image 1
?>
<?
//upload image 2
for($i=0;$i<count($_FILES["fileUpload2"]["name"]);$i++)
{
if(trim($_FILES["fileUpload2"]["tmp_name"][$i]) != "")
{
$images = $_FILES["fileUpload2"]["tmp_name"][$i];
$new_images = $_FILES["fileUpload2"]["name"][$i];
copy($_FILES["fileUpload2"]["tmp_name"][$i],"MyResize/$txtUsername"."_2_".$_FILES["fileUpload2"]["name"][$i]);
$width=640; //*** Fix Width & Heigh (Autu caculate) ***//
$size=GetimageSize($images);
$height=round($width*$size[1]/$size[0]);
$images_orig = ImageCreateFromJPEG($images);
$photoX = ImagesX($images_orig);
$photoY = ImagesY($images_orig);
$images_fin = ImageCreateTrueColor($width, $height);
ImageCopyResampled($images_fin, $images_orig, 0, 0, 0, 0, $width+1, $height+1, $photoX, $photoY);
ImageJPEG($images_fin,"MyResize/$txtUsername".$new_images);
ImageDestroy($images_orig);
ImageDestroy($images_fin);
//User Make No Echo //echo "Resize Successful.<br>";
//*** Insert Record ***//
$objConnect = mysql_connect("localhost","library","compaq") or die("Error Connect to Database");
$objDB = mysql_select_db("library");
$strSQL = "INSERT INTO book_image";
$strSQL .="(image_path,book_isbn,image_type) VALUES
('"."MyResize/".$_POST['txtUsername']."_2_".$_FILES["fileUpload2"]["name"][$i]."','".$_POST['txtUsername']."','2')";
$objQuery = mysql_query($strSQL) or die(mysql_error());
}
}
//end upload image 2
?>
<?
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$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;
}
}
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$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;
}
}
mysql_select_db($database_library, $library);
$query_booktype = "SELECT * FROM booktype";
$booktype = mysql_query($query_booktype, $library) or die(mysql_error());
$row_booktype = mysql_fetch_assoc($booktype);
$totalRows_booktype = mysql_num_rows($booktype);
mysql_select_db($database_library, $library);
$query_press = "SELECT * FROM press";
$press = mysql_query($query_press, $library) or die(mysql_error());
$row_press = mysql_fetch_assoc($press);
$totalRows_press = mysql_num_rows($press);
?><!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>Add book List</title>
<link href="images/Control_text.css" rel="stylesheet" type="text/css" />
<style type="text/css">
@import url("css.css");
</style>
<script type="text/javascript">
<!--
function MM_goToURL() { //v3.0
var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
//-->
</script>
</head>
<body>
<form name="form1" method="post" action="<?php echo $editFormAction; ?> " enctype="multipart/form-data" onSubmit="JavaScript:return fncSubmit();" >
<script language="JavaScript">
//check input only number
function chkNumber(ele)
{
var vchar = String.fromCharCode(event.keyCode);
if ((vchar<'0' || vchar>'9') && (vchar != '.')) return false;
ele.onKeyPress=vchar;
}
</script>
<script language="JavaScript">
//check isbn
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 = 'AjaxPHPRegister2.php';
var pmeters = "tUsername=" + encodeURI( document.getElementById("txtUsername").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 == 3) // Loading Request
{
document.getElementById("mySpan").innerHTML = "..";
}
if(HttPRequest.readyState == 4) // Return Request
{
if(HttPRequest.responseText == 'Y')
{
window.location = 'AjaxPHPRegister3.php';
}
else
{
document.getElementById("mySpan").innerHTML = HttPRequest.responseText;
}
}
}
}
</script>
<script language="JavaScript">
//disable enter or blackspace
document.onkeydown = chkEvent
var formInUse = false;
function chkEvent(e) {
var keycode;
if (window.event) keycode = window.event.keyCode; //*** for IE ***//
else if (e) keycode = e.which; //*** for Firefox ***//
if(keycode==13 && formInUse==false)//disable enter
//if(keycode==13 || (keycode==8 && formInUse==false))//disable enter or blackspace
{
return false;
}
}
//end disable enter or blackspace
</script>
<script language="javascript">
//check Input
function fncSubmit()
{
if(document.form1.txtUsername.value == "" )
{
alert('กรุณาตรวจสอบเลข ISBN อีกครั้ง');
document.form1.txtUsername.focus();
//
return false;
}
if(document.form1.book_name.value == "")
{
alert('กรุณากรอกชื่อหนังสือ');
document.form1.book_name.focus();
//
//
return false;
}
if(document.form1.book_number_number.value == "")
{
alert('กรุณากรอกเลขทะเบียน');
document.form1.book_number_number.focus();
//
//
return false;
}
if(document.form1.book_coppy.value == "")
{
alert('กรุณากรอกฉบับ');
document.form1.book_coppy.focus();
//
//
return false;
}
if(document.form1.book_author.value == "")
{
alert('กรุณากรอกชื่อผู้แต่ง');
document.form1.book_author.focus();
//
//
return false;
}
if(document.form1.book_page.value == "")
{
alert('กรุณากรอกจำนวนหน้า');
document.form1.book_page.focus();
//
//
return false;
}
if(document.form1.book_timeprint.value == "")
{
alert('กรุณากรอกครั้งที่พิมพ์');
document.form1.book_timeprint.focus();
//
//
return false;
}
if(document.form1.book_booktype.value == "0")
{
alert('กรุณาเลือกประเภทหนังสือ');
//
//
return false;
}
if(document.form1.book_press.value == "0")
{
alert('กรุณาเลือกสำนักพิมพ์');
//
//
return false;
}
if(document.form1.fileUpload.value == "")
{
alert('กรุณาเลือกรูป');
//
return false;
}
document.form1.submit();
}
//end check input
</script>
<table width="80%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="47" colspan="3"><div align="center" class="style14">เพิ่มหนังสือใหม่</div></td>
</tr>
<tr>
<td width="29%" class="style13">ISBN</td>
<td width="45%"><label>
<input name="txtUsername" type="text" id="txtUsername" OnChange="JavaScript:doCallAjax();" OnKeyPress="return chkNumber(this)" maxlength="13" >
<span id="mySpan"></span>
</label></td>
<td width="19%"> </td>
</tr>
<tr>
<td class="style13">ชื่อหนังสือ</td>
<td><label>
<input name="book_name" type="text" id="book_name" maxlength="30" />
</label></td>
<td> </td>
</tr>
<tr>
<td class="style13" >เลขทะเบียน</td>
<td><label>
<input name="book_number_number" type="text" id="book_number_number" maxlength="6" />
</label></td>
<td> </td>
</tr>
<tr>
<td class="style13" >ฉบับ</td>
<td><input name="book_coppy" type="text" id="book_coppy" maxlength="2" onkeypress="return chkNumber(this)" /></td>
<td> </td>
</tr>
<tr>
<td class="style13" >ชื่อผู้แต่ง</td>
<td><label>
<input name="book_author" type="text" id="book_author" maxlength="60" />
</label></td>
<td> </td>
</tr>
<tr>
<td class="style13" >จำนวนหน้า</td>
<td><label>
<input name="book_page" type="text" id="book_page" onkeypress="return chkNumber(this)" maxlength="5"/>
</label></td>
<td> </td>
</tr>
<tr>
<td class="style13" >ครั้งที่พิมพ์</td>
<td><label>
<input name="book_timeprint" type="text" id="book_timeprint" onkeypress="return chkNumber(this)" maxlength="2" />
</label></td>
<td> </td>
</tr>
<tr>
<td class="style13" >ประเภทหนังสือ</td>
<td><label>
<select name="book_booktype" id="book_booktype">
<option value="0">= กรุณาเลือก =</option>
<?php
do {
?>
<option value="<?php echo $row_booktype['booktype_id']?>"><?php echo $row_booktype['booktype_name']?></option>
<?php
} while ($row_booktype = mysql_fetch_assoc($booktype));
$rows = mysql_num_rows($booktype);
if($rows > 0) {
mysql_data_seek($booktype, 0);
$row_booktype = mysql_fetch_assoc($booktype);
}
?>
</select>
</label></td>
<td> </td>
</tr>
<tr>
<td class="style13" >สำนักพิมพ์</td>
<td><label>
<select name="book_press" id="book_press">
<option value="0">= กรุณาเลือก =</option>
<?php
do {
?>
<option value="<?php echo $row_press['press_id']?>"><?php echo $row_press['press_name']?></option>
<?php
} while ($row_press = mysql_fetch_assoc($press));
$rows = mysql_num_rows($press);
if($rows > 0) {
mysql_data_seek($press, 0);
$row_press = mysql_fetch_assoc($press);
}
?>
</select>
</label></td>
<td> </td>
</tr>
<tr>
<td class="style13">รายละเอียดหนังสือ</td>
<td><label>
<textarea name="book_detail" id="book_detail" maxlength="300"></textarea>
</label></td>
<td> </td>
</tr>
<?php
/*** By Weerachai Nukitram ***/ /*** http://www.ThaiCreate.Com ***/
$objConnect3 = mysql_connect("localhost","library","compaq") or die("Error Connect to Database");
$objDB2 = mysql_select_db("library");
@mysql_query("SET NAMES UTF8");
?>
<script language = "JavaScript">
//**** List Province (Start) ***//
function ListProvince(SelectValue)
{
frmMain.ddlProvince.length = 0
//*** Insert null Default Value ***//
var myOption = new Option('','')
frmMain.ddlProvince.options[frmMain.ddlProvince.length]= myOption
<?
$intRows = 0;
$strSQL7 = "SELECT * FROM book_sub_group";
$objQuery7 = mysql_query($strSQL7) or die ("Error Query [".$strSQL7."]");
$intRows = 0;
while($objResult7 = mysql_fetch_array($objQuery7))
{
$intRows++;
?>
x = <?=$intRows;?>;
mySubList = new Array();
strGroup = <?=$objResult7["book_group_id"];?>;
strValue = "<?=$objResult7["book_sub_group_id"];?>";
strItem = "<?=$objResult7["book_sub_group_name"];?>";
mySubList[x,0] = strItem;
mySubList[x,1] = strGroup;
mySubList[x,2] = strValue;
if (mySubList[x,1] == SelectValue){
var myOption = new Option(mySubList[x,0], mySubList[x,2])
frmMain.ddlProvince.options[frmMain.ddlProvince.length]= myOption
}
<?
}
?>
}
//**** List Province (End) ***//
function MM_goToURL() { //v3.0
var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
</script>
</head>
<form name="frmMain" method="POST">
<tr>
<td class="style13">หมวดหลัก</td>
<td>
<select id="ddlGeo" name="ddlGeo" onChange = "ListProvince(this.value)">
<option selected value=""></option>
<?
$strSQL8 = "SELECT * FROM book_group ";
$objQuery8 = mysql_query($strSQL8) or die ("Error Query [".$strSQL8."]");
while($objResult8 = mysql_fetch_array($objQuery8))
{
?>
<option value="<?=$objResult8["book_group_id"];?>"><?=$objResult8["book_groyp_name"];?></option>
<?
}
?>
</select>
</td>
<td> </td>
</tr>
<tr>
<td class="style13">หมวดย่อย</td>
<td>
<select id="ddlProvince" name="ddlProvince" style="width:120px" onChange = "ListAmphur(this.value)"></select>
</td>
<td> </td>
</tr>
</form>
<?
mysql_close($objConnect3);
?>
<tr>
<td rowspan="3" class="style13" >รูปภาพ<br><br></td>
<td><br>
<form name="form2" method="post" action="phpMultiUploadResizeToMySQL2.php" enctype="multipart/form-data" onSubmit="JavaScript:return fncSubmit();">
<label> <input type="file" name="fileUpload[]"><br>
<input type="file" name="fileUpload[]">
<br>
<input type="file" name="fileUpload[]"><br>
<p>===================</p>
<p>
<input type="file" name="fileUpload2[]">
<br>
<input type="file" name="fileUpload2[]">
<br>
<input type="file" name="fileUpload2[]">
<br>
<input type="file" name="fileUpload2[]">
<br>
<input type="file" name="fileUpload2[]">
<br>
<input type="file" name="fileUpload2[]">
<br>
<input type="file" name="fileUpload2[]">
<br>
</label>
</p>
<p class="style9">* ขนาดไม่เกิน 1024x768 Pixels</p>
</form>
</td>
<td class="style13" ><p>ปก<br><br><br></p>
<p> </p>
<p> </p>
<p>สารบัญ</p></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td colspan="3"><div align="center">
<label>
<input type="submit" name="btnSubmit" id="acc" value="ตกลง" /></label>
<label>
<input name="btn_can" type="button" id="btn_can" onclick="MM_goToURL('parent','administrator_book.php');return document.MM_returnValue" value="ยกเลิก" />
</label>
</div></td>
</tr>
</table>
<p> </p>
<p class="text_line"> </p>
<input type="hidden" name="MM_insert" value="form1" />
<input type="hidden" name="MM_insert" value="form1" />
</form>
</body>
</html>
<?php
mysql_free_result($press);
mysql_free_result($booktype);
?>
Tag : PHP, MySQL, HTML/CSS, JavaScript, Ajax
|
ประวัติการแก้ไข 2012-06-03 04:01:25
|
|
|
|
|
Date :
2012-06-03 03:58:47 |
By :
numprick |
View :
849 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ดูพวกชื่อ form อะไรให้ดีครับ ว่าแต่ทำไมถึงมี <form> 2 ตัวครับ
|
|
|
|
|
Date :
2012-06-03 07:39:47 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ตอบความคิดเห็นที่ : 1 เขียนโดย : mr.win เมื่อวันที่ 2012-06-03 07:39:47
รายละเอียดของการตอบ ::
ตอนแรกผมเอา ชุด dependant มาใส่เลยครับ
ตอนนี้ได้ทำการเอามารวมกันแล้วครับ ใน FORM1
ที่มีอยู๋ เดิม
และทำการประชื่อ FORM ให้ตรงกัน
ตัวที่ใช้งานได้แล้ว
Code (PHP)
<?
$objConnect3 = mysql_connect("localhost","library","compaq") or die("Error Connect to Database");
$objDB2 = mysql_select_db("library");
@mysql_query("SET NAMES UTF8");
?>
<script language = "JavaScript">
//dependantlistmeny
//**** List Province (Start) ***//
function ListProvince(SelectValue)
{
form1.ddlProvince.length = 0
//frmMain.ddlAmphur.length = 0
//*** Insert null Default Value ***//
var myOption = new Option('','')
form1.ddlProvince.options[form1.ddlProvince.length]= myOption
<?
$intRows = 0;
$strSQL7 = "SELECT * FROM book_sub_group";
$objQuery7 = mysql_query($strSQL7) or die ("Error Query [".$strSQL7."]");
$intRows = 0;
while($objResult7 = mysql_fetch_array($objQuery7))
{
$intRows++;
?>
x = <?=$intRows;?>;
mySubList = new Array();
strGroup = <?=$objResult7["book_group_id"];?>;
strValue = "<?=$objResult7["book_sub_group_id"];?>";
strItem = "<?=$objResult7["book_sub_group_name"];?>";
mySubList[x,0] = strItem;
mySubList[x,1] = strGroup;
mySubList[x,2] = strValue;
if (mySubList[x,1] == SelectValue){
var myOption = new Option(mySubList[x,0], mySubList[x,2])
form1.ddlProvince.options[form1.ddlProvince.length]= myOption
}
<?
}
?>
}
//**** List Province (End) ***//
function MM_goToURL() { //v3.0
var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
//end dependantlistmeny
</script>
<table width="80%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="47" colspan="3"><div align="center" class="style14">เพิ่มหนังสือใหม่</div></td>
</tr>
<tr>
<td width="29%" class="style13">ISBN</td>
<td width="45%"><label>
<input name="txtUsername" type="text" id="txtUsername" OnChange="JavaScript:doCallAjax();" OnKeyPress="return chkNumber(this)" maxlength="13" >
<span id="mySpan"></span>
</label></td>
<td width="19%"> </td>
</tr>
<tr>
<td class="style13">ชื่อหนังสือ</td>
<td><label>
<input name="book_name" type="text" id="book_name" maxlength="30" />
</label></td>
<td> </td>
</tr>
<tr>
<td class="style13" >เลขทะเบียน</td>
<td><label>
<input name="book_number_number" type="text" id="book_number_number" maxlength="6" />
</label></td>
<td> </td>
</tr>
<tr>
<td class="style13" >ฉบับ</td>
<td><input name="book_coppy" type="text" id="book_coppy" maxlength="2" onkeypress="return chkNumber(this)" /></td>
<td> </td>
</tr>
<tr>
<td class="style13" >ชื่อผู้แต่ง</td>
<td><label>
<input name="book_author" type="text" id="book_author" maxlength="60" />
</label></td>
<td> </td>
</tr>
<tr>
<td class="style13" >จำนวนหน้า</td>
<td><label>
<input name="book_page" type="text" id="book_page" onkeypress="return chkNumber(this)" maxlength="5"/>
</label></td>
<td> </td>
</tr>
<tr>
<td class="style13" >ครั้งที่พิมพ์</td>
<td><label>
<input name="book_timeprint" type="text" id="book_timeprint" onkeypress="return chkNumber(this)" maxlength="2" />
</label></td>
<td> </td>
</tr>
<tr>
<td class="style13" >ประเภทหนังสือ</td>
<td><label>
<select name="book_booktype" id="book_booktype">
<option value="0">= กรุณาเลือก =</option>
<?php
do {
?>
<option value="<?php echo $row_booktype['booktype_id']?>"><?php echo $row_booktype['booktype_name']?></option>
<?php
} while ($row_booktype = mysql_fetch_assoc($booktype));
$rows = mysql_num_rows($booktype);
if($rows > 0) {
mysql_data_seek($booktype, 0);
$row_booktype = mysql_fetch_assoc($booktype);
}
?>
</select>
</label></td>
<td> </td>
</tr>
<tr>
<td class="style13" >สำนักพิมพ์</td>
<td><label>
<select name="book_press" id="book_press">
<option value="0">= กรุณาเลือก =</option>
<?php
do {
?>
<option value="<?php echo $row_press['press_id']?>"><?php echo $row_press['press_name']?></option>
<?php
} while ($row_press = mysql_fetch_assoc($press));
$rows = mysql_num_rows($press);
if($rows > 0) {
mysql_data_seek($press, 0);
$row_press = mysql_fetch_assoc($press);
}
?>
</select>
</label></td>
<td> </td>
</tr>
<tr>
<td class="style13" >Geography </td>
<td>
<select id="ddlGeo" name="ddlGeo" onChange = "ListProvince(this.value)">
<?
$strSQL8 = "SELECT * FROM book_group ";
$objQuery8 = mysql_query($strSQL8) or die ("Error Query [".$strSQL8."]");
while($objResult8 = mysql_fetch_array($objQuery8))
{
?>
<option value="<?=$objResult8["book_group_id"];?>"><?=$objResult8["book_groyp_name"];?></option>
<?
}
?>
</select>
<td> </td>
</tr>
<tr>
<td class="style13" >Province</td>
<td>
<select id="ddlProvince" name="ddlProvince" style="width:120px" onChange = "ListAmphur(this.value)">
</select>
<td> </td>
</tr>
<?
mysql_close($objConnect3);
?>
ขอขอบคุณ thaicreate และพี่ๆทุกคนครับ
|
|
|
|
|
Date :
2012-06-03 11:57:53 |
By :
numprick |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|