|
 |
|
ขอคำแนะนำจากพี่ๆ เกี่ยวการทำ sublist พอดีทำแล้วไม่ประสบผลสำเร็จน่ะคะ ขอคำแนะนำเพิ่มเติมด้วยค่ะ |
|
 |
|
|
 |
 |
|

นี่เป็นโค้ด
Code (PHP)
<?php
include("connect_db.php");
$objParse = oci_parse ($objConnect, $strSQL);
oci_execute ($objParse,OCI_DEFAULT);
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>การทำ sublist</title>
<script language = "JavaScript">
//**** List Program (Start) ***//
function ListProgram(SelectValue)
{
frmMain.ddlProgram.length = 0
frmMain.ddlCourse.length = 0
//*** Insert null Default Value ***//
var myOption = new Option('','')
frmMain.ddlProgram.options[frmMain.ddlProvince.length]= myOption
<?
$intRows = 0;
$strSQL = "SELECT DISTINCT
AVSREG.PROGRAM.PROGRAMID,
AVSREG.PROGRAM.PROGRAMNAME
FROM
AVSREG.PROGRAM
ORDER BY
AVSREG.PROGRAM.PROGRAMID ASC";
$objParse = oci_parse ($objConnect, $strSQL);
oci_execute ($objParse,OCI_DEFAULT);
$intRows = 0;
while($objResult = oci_fetch_array($objParse,OCI_BOTH))
{
$intRows++;
?>
x = <?=$intRows;?>;
mySubList = new Array();
strGroup = <?=$objResult["FACULTYID"];?>;
strValue = "<?=$objResult["PROGRAMID"];?>";
strItem = "<?=$objResult["PROGRAMNAME"];?>";
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.ddlProgram.options[frmMain.ddlProgram.length]= myOption
}
<?
}
?>
}
//**** List Program (End) ***//
//**** List Course (Start) ***//
function ListCourse(SelectValue)
{
frmMain.ddlCourse.length = 0
//*** Insert null Default Value ***//
var myOption = new Option('','')
frmMain.ddlCourse.options[frmMain.ddlCourse.length]= myOption
<?
$intRows = 0;
$strSQL = "SELECT DISTINCT
AVSREG.COURSE.COURSECODE,
AVSREG.COURSE.COURSENAME,
AVSREG.COURSE.COURSEID
FROM
AVSREG.COURSE
ORDER BY
AVSREG.COURSE.COURSEID ASC
";
$objParse = oci_parse ($objConnect, $strSQL);
oci_execute ($objParse,OCI_DEFAULT);
$intRows = 0;
while($objResult = oci_fetch_array($objParse,OCI_BOTH))
{
$intRows++;
?>
x = <?=$intRows;?>;
mySubList = new Array();
strGroup = <?=$objResult["PROGRAMID"];?>;
strValue = "<?=$objResult["COURSEID"];?>";
strItem = "<?=$objResult["COURSENAME"];?>";
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.ddlCourse.options[frmMain.ddlCourse.length]= myOption
}
<?
}
?>
}
//**** List Course (End) ***//
</script>
<style type="text/css">
<!--
body,td,th {
font-family: Angsana New;
font-size: 18px;
}
a {
font-family: Angsana New;
font-size: 18px;
}
h1,h2,h3,h4,h5,h6 {
font-family: Angsana New;
}
h1 {
font-size: 18px;
}
.style1 {
font-size: 24px;
font-weight: bold;
}
-->
</style></head>
<form name="frmMain" action="" method="post">
<span class="style1">คณะ :</span>
<select id="Faculty" name="Faculty" onChange = "ListFaculty(this.value)">
<option selected value="">--เลือกคณะ--</option>
<?
$strSQL = "SELECT DISTINCT
AVSREG.FACULTY.FACULTYID,
AVSREG.FACULTY.FACULTYNAME
FROM
AVSREG.FACULTY
WHERE FACULTYID BETWEEN '1' AND '4'
ORDER BY FACULTYID ASC";
$objParse = oci_parse ($objConnect, $strSQL);
oci_execute ($objParse,OCI_DEFAULT);
while($objResult = oci_fetch_array($objParse,OCI_BOTH))
{
?>
<option value="<?=$objResult["FACULTYID"];?>"><?=$objResult["FACULTYNAME"];?></option>
<?
}
?>
</select>
<span class="style1">สาขาวิชา :</span>
<select id="ddlProgram" name="ddlProgram" style="width:120px" onChange = "ListCourse(this.value)">--เลือกสาขาวิชา--</select>
<span class="style1">รายวิชา :</span>
<select id="ddlCourse" name="ddlCourse" style="width:200px">--เลือกรายวิชา--</select>
</form>
</body>
</html>
<?
oci_close($objConnect);
?>
Tag : PHP, Oracle, JavaScript

|
|
 |
 |
 |
 |
Date :
2012-04-01 14:29:04 |
By :
comerror |
View :
1196 |
Reply :
5 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ก็ คำสั่ง เลือกคณะ ของน้องเป็นแบบนี้
<select id="Faculty" name="Faculty" onChange = "ListFaculty(this.value)">
คำสั่งคือ ใช้ onChange(เมื่อเปลี่ยน) ให้เรียกฟังชัน ListFaculty ซึ่งฟังชันดังกล่าว ไม่มีอยู่ใน โค้ดของน้องครับ
|
 |
 |
 |
 |
Date :
2012-04-01 15:05:16 |
By :
50121680 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ก็ให้สังเกตุว่า แต่ละ dropdown เรียกฟังชันอะไร แล้วก็ให้ไปดูว่าฟังชันทำอะไรบ้างครับ
|
 |
 |
 |
 |
Date :
2012-04-02 08:40:41 |
By :
50121680 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
พี่ค่ะ ผลลัพธ์ก็ยังไม่แสดงเหมือนเดิมค่ะ หนูไม่รู้จริงๆว่าทำไมไม่แสดงออกมา หนูลอง view source ดู ก็มีแสดงข้อมูล

ตามโค้ดค่ะ
Code (PHP)
<?php
include("connect_db.php");
$objParse = oci_parse ($objConnect, $strSQL);
oci_execute ($objParse,OCI_DEFAULT);
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>การทำ sublist</title>
<script language = "JavaScript">
//**** List Program (Start) ***//
function ListProgram(SelectValue)
{
frmMain.ddlProgram.length = 0
frmMain.ddlCourse.length = 0
//*** Insert null Default Value ***//
var myOption = new Option('','')
frmMain.ddlProgram.options[frmMain.ddlProvince.length]= myOption
<?
$intRows = 0;
$strSQL = "SELECT
DISTINCT EVALUATE.EV1.PROGRAMNAME,
EVALUATE.EV1.COURSEID,
EVALUATE.EV1.COURSECODE,
EVALUATE.EV1.COURSENAME,
EVALUATE.EV1.PROGRAMID
FROM
EVALUATE.EV1
ORDER BY
EVALUATE.EV1.PROGRAMID ASC";
$objParse = oci_parse ($objConnect, $strSQL);
oci_execute ($objParse,OCI_DEFAULT);
$intRows = 0;
while($objResult = oci_fetch_array($objParse,OCI_BOTH))
{
$intRows++;
?>
x = <?=$intRows;?>;
mySubList = new Array();
strGroup = <?=$objResult["FACULTYID"];?>;
strValue = "<?=$objResult["PROGRAMID"];?>";
strItem = "<?=$objResult["PROGRAMNAME"];?>";
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.ddlProgram.options[frmMain.ddlProgram.length]= myOption
}
<?
}
?>
}
//**** List Program (End) ***//
//**** List Course (Start) ***//
function ListCourse(SelectValue)
{
frmMain.ddlCourse.length = 0
//*** Insert null Default Value ***//
var myOption = new Option('','')
frmMain.ddlCourse.options[frmMain.ddlCourse.length]= myOption
<?
$intRows = 0;
$strSQL = "SELECT
DISTINCT EVALUATE.EV1.PROGRAMNAME,
EVALUATE.EV1.COURSEID,
EVALUATE.EV1.COURSECODE,
EVALUATE.EV1.COURSENAME,
EVALUATE.EV1.PROGRAMID
FROM
EVALUATE.EV1
ORDER BY
EVALUATE.EV1.PROGRAMID ASC
";
$objParse = oci_parse ($objConnect, $strSQL);
oci_execute ($objParse,OCI_DEFAULT);
$intRows = 0;
while($objResult = oci_fetch_array($objParse,OCI_BOTH))
{
$intRows++;
?>
x = <?=$intRows;?>;
mySubList = new Array();
strGroup = <?=$objResult["PROGRAMID"];?>;
strValue = "<?=$objResult["COURSEID"];?>";
strItem = "<?=$objResult["COURSENAME"];?>";
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.ddlCourse.options[frmMain.ddlCourse.length]= myOption
}
<?
}
?>
}
//**** List Course (End) ***//
</script>
<style type="text/css">
<!--
body,td,th {
font-family: Angsana New;
font-size: 18px;
}
a {
font-family: Angsana New;
font-size: 18px;
}
h1,h2,h3,h4,h5,h6 {
font-family: Angsana New;
}
h1 {
font-size: 18px;
}
.style1 {
font-size: 24px;
font-weight: bold;
}
-->
</style></head>
<form name="frmMain" action="" method="post">
<span class="style1">คณะ :</span>
<select id="Faculty" name="Faculty" onChange = "ListProgram(this.value)">
<option selected value="">--เลือกคณะ--</option>
<?
$strSQL = "SELECT DISTINCT
AVSREG.FACULTY.FACULTYID,
AVSREG.FACULTY.FACULTYNAME
FROM
AVSREG.FACULTY
WHERE FACULTYID BETWEEN '1' AND '4'
ORDER BY FACULTYID ASC";
$objParse = oci_parse ($objConnect, $strSQL);
oci_execute ($objParse,OCI_DEFAULT);
while($objResult = oci_fetch_array($objParse,OCI_BOTH))
{
?>
<option value="<?=$objResult["FACULTYID"];?>"><?=$objResult["FACULTYNAME"];?></option>
<?
}
?>
</select>
<span class="style1">สาขาวิชา :</span>
<select id="ddlProgram" name="ddlProgram" style="width:120px" onChange = "ListCourse(this.value)">--เลือกสาขาวิชา--</select>
<span class="style1">รายวิชา :</span>
<select id="ddlCourse" name="ddlCourse" style="width:200px">--เลือกรายวิชา--</select>
</form>
</body>
</html>
<?
oci_close($objConnect);
?>
ช่วยหน่อยน่ะค่ะ หนูไปไม่ได้จริงๆค่ะ
|
 |
 |
 |
 |
Date :
2012-04-09 21:35:37 |
By :
comerror |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|