|
|
|
สอบถามการใช้ select 2 อันครับ มันไม่ขึ้นข้อมูล รยกวนช่วยดูให้หน่อยนะคับบ |
|
|
|
|
|
|
|
อยากให้พอเลือก select อันแรกแล้ว นำค่า $sv_id มา select * from smssubservice where SVID = '$sv_id' order by SVID ใน select ที่ 2 คับ ผมทำแล้วมันไม่ขึ้นข้อมูลใน select ที่ 2 เลยคับ รบกวนช่วย ดูให้หน่อยคับ (ผมพึ่งหัดเขียนคับบ )
Code (PHP)
<script type="text/javascript">
function ListSMSSS(SelectValue)
{
form1.subsmsss.length = 0
//*** Insert null Default Value ***//
var myOption = new Option('','')
form1.subsmsss.options[form1.subsmsss.length]= myOption
<?
$intRows = 0;
$sqlsubsms = "select * from smssubservice where SVID = '$sv_id' order by SVID";
$stmtsubsms = ociparse($conn,$sqlsubsms) or die(mysql_error());
ociexecute($stmtsubsms);
$intRows = 0;
while(OCIfetch($stmtsubsms)){
$intRows++;
$sv_id = ociresult($stmtsubsms,'SVID');
$subsv_id = ociresult($stmtsubsms,'SUBSVID');
$subsv_name = ociresult($stmtsms,'SUBSVNAME');
?>
x = <?=$intRows;?>;
mySubList = new Array();
strGroup = <?=$sv_id?>;
strValue = "<?=$subsv_id?>";
strItem = "<?=$subsv_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.subsmsss.options[form1.subsmsss.length]= myOption
}
<?
}
?>
}
</script>
Code (PHP)
<table cellpadding="0">
<tr>
<td align="right">
<form name="form1" id="form1" method="POST" action="random_test.php">
Service : </td>
<td><select name="smsss" id="smsss" onChange= "ListSMSSS(this.value)">
<option value=""><-- Please Select --></option>
<?php
$sqlsms = "select SVID, SVNAME from smsservice order by SVID";
$stmtsms = ociparse($conn,$sqlsms) or die(mysql_error());
ociexecute($stmtsms);
while(OCIfetch($stmtsms)){
$sv_id = ociresult($stmtsms,'SVID');
$sv_name = ociresult($stmtsms,'SVNAME');
echo "<option value='$sv_id'>"."(".$sv_id.")".$sv_name."</option>";
}
?>
</select>
</td>
</tr>
<tr>
<td><br/> Sub Service : </td>
<td align="left"><br/>
<select name="subsmsss" id= "subsmsss">
<option value=""><-- Please Select --></option>
</select>
</td>
</tr>
</table>
Tag : PHP
|
|
|
|
|
|
Date :
2011-09-08 13:40:57 |
By :
l3ankkiZ |
View :
1205 |
Reply :
5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (JavaScript)
strGroup = "<?=$sv_id?>";
ลองดูครับ ไม่รู้จะเกี่ยวหรือเปล่าครับ เพราะถ้าตัวนี้เป็น string จะ error ทันทีครับ
|
|
|
|
|
Date :
2011-09-08 16:32:20 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ลองแล้วคับ มันยังไม่ได้เลยอ่าคับ
|
|
|
|
|
Date :
2011-09-08 16:46:10 |
By :
l3ankkiZ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
น่าจะถูกต้องนะครับ เพราะมันโชว์ list ตามที่ต้องการเลยอ่าคับ แต่ select ที่ 2 มันไม่ออก ผมงงๆคือตรงสคริปนี่ล่ะคับ ผมไม่ถนัดเลยจิงๆ T^T
|
|
|
|
|
Date :
2011-09-08 18:08:41 |
By :
l3ankkiZ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
พี่ mr.win คับ
คราวนี้ลิสต์มันขึ้นช่องตามจำนวนrecord ที่มีอยู่ในฐานข้อมูล แถมมันยังเพิ่มมาให้อีก 1 แถว อ่าคับ มันไม่ขึ้นข้อมูล ทำอย่างไรคับ รบกวนด้วยนะคับ
Code (PHP)
<script language="JavaScript">
function ListSMSSS(SelectValue)
{
form1.subsmsss.length = 0
//*** Insert null Default Value ***//
var myOption = new Option('','')
form1.subsmsss.options[form1.subsmsss.length]= myOption
<?
$intRows = 0;
$sqlsubsms = "select * from smssubservice order by SUBSVID";
$stmtsubsms = ociparse($conn,$sqlsubsms) or die(mysql_error());
ociexecute($stmtsubsms);
$intRows = 0;
while(OCIfetch($stmtsubsms)){
$intRows++;
?>
x = <?=$intRows;?>;
mySubList = new Array();
strGroup = "<?=$sv_id = ociresult($stmtsubsms,'SVID');?>";
strValue = "<?=$subsv_id = ociresult($stmtsubsms,'SUBSVID');?>";
strItem = "<?=$subsv_name = ociresult($stmtsms,'SUBSVNAME');?>";
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.subsmsss.options[form1.subsmsss.length]= myOption
}
<?
}
?>
}
</script>
<title></title>
</head>
<body OnLoad="setDefault()">
<script language = "JavaScript">
function setDefault()
{
<?
/*** ค่า Default ที่ได้จากการจัดเก็บ ***/
$strSmsservice = "444";
$strSmssubservice = "1161";
?>
<?
if($strSmsservice != "")
{
?>
var objSMS=document.form1.smsservice;
for (x=0;x<objSMS.length;x++)
{
if (objSMS.options[x].value=="<?=$strSmsservice?>")
{
objSMS.options[x].selected = true;
break;
}
}
ListSMSSS(<?=$strSmsservice?>)
<?
}
?>
<?
if($strSmssubservice != "")
{
?>
var objSubservice=document.form1.subsmsss;
for (x=0;x<objSubservice.length;x++)
{
if (objSubservice.options[x].value=="<?=$strSmssubservice?>")
{
objSubservice.options[x].selected = true;
break;
}
}
<?
}
?>
}
</script>
<ul id="countrytabs" class="shadetabs">
<li><a href="#" rel="country1" class="selected">LoadData</a></li>
<li><a href="#" rel="country2">Random</a></li>
</ul>
<div style="border:0px solid gray; width: 900px; margin-bottom: 1em; padding: 10px">
<br/>
<br/>
<center>
<div id="country1" class="tabcontent">
<table cellpadding="0">
<tr>
<td align="right">
<form name="form1" id="form1" method="POST" action="random_test.php">
Service : </td>
<td><select name="smsss" id="smsss" onChange= "ListSMSSS(this.value)">
<option selected value=""><-- Please Select --></option>
<?php
$sqlsms = "select * from smsservice order by SVID";
$stmtsms = ociparse($conn,$sqlsms) or die(mysql_error());
ociexecute($stmtsms);
while(OCIfetch($stmtsms)){
?>
<option value="<?=$sv_id = ociresult($stmtsms,'SVID');?>">(<?=$sv_id = ociresult($stmtsms,'SVID');?>)<?= $sv_name = ociresult($stmtsms,'SVNAME'); ?></option>
<?
}
?>
</select>
</td>
</tr>
<tr>
<td><br/> Sub Service : </td>
<td align="left"><br/>
<select name="subsmsss" id= "subsmsss" style="width:120px" ></select>
</td>
</tr>
<tr>
<td align="right"><br/>
<select name="dm" id="dm" onchange="fncShowHide(this.value);">
<option value="1">Daily</option>
<option value="2">Monthly</option>
</select>
</td>
<td align="left"><br/>
<span id="cal1" >
<input name="day1" type="text" style="width: 18px; border-width: 1px 0 1px 1px;" maxlength="2" /><input value="/" type="text" style="width: 5px; border-width: 1px 0 1px 0;" disabled="disabled" /><input name="month1" class="textbox" type="text" style="width: 16px; border-width: 1px 0 1px 0;" maxlength="2" /><input value="/" type="text" style="width: 5px; border-width: 1px 0 1px 0;" disabled="disabled" /><input name="year1" type="text" style="width: 28px; border-width: 1px 0 1px 0;" maxlength="4" /><input type="text" style="width: 15px; border-width: 1px 1px 1px 0;" disabled="disabled" /><img src="images/calendar.gif" id="togglePicker" class="pickerImg" width="13px" height="12px" alt="" />
to
</span>
<span id="cal2" >
<input name="day2" type="text" style="width: 18px; border-width: 1px 0 1px 1px;" maxlength="2" /><input value="/" type="text" style="width: 5px; border-width: 1px 0 1px 0;" disabled="disabled" /><input name="month2" class="textbox" type="text" style="width: 16px; border-width: 1px 0 1px 0;" maxlength="2" /><input value="/" type="text" style="width: 5px; border-width: 1px 0 1px 0;" disabled="disabled" /><input name="year2" type="text" style="width: 28px; border-width: 1px 0 1px 0;" maxlength="4" /><input type="text" style="width: 15px; border-width: 1px 1px 1px 0;" disabled="disabled" /><img src="images/calendar.gif" id="togglePicker2" class="pickerImg" width="13px" height="12px" alt="" />
</span>
<span id="cal3" style="display:none;">
<input name="month3" class="textbox" value="MM" type="text" style="width: 22px; border-width: 1px 0 1px 0;" maxlength="2" /><input value="/" type="text" style="width: 5px; border-width: 1px 0 1px 0;" disabled="disabled" /><input name="year3" value="YYYY" type="text" style="width: 36px; border-width: 1px 0 1px 0;" maxlength="4" />
to
<input name="month4" class="textbox" value="MM" type="text" style="width: 22px; border-width: 1px 0 1px 0;" maxlength="2" /><input value="/" type="text" style="width: 5px; border-width: 1px 0 1px 0;" disabled="disabled" /><input name="year4" value="YYYY" type="text" style="width: 36px; border-width: 1px 0 1px 0;" maxlength="4" />
</span>
</td>
</tr>
<tr>
<td colspan="2">
<br/><input name= "btnsubmit1" type= "submit" value="Load" id="inputbtn" class="inputbtn"></td>
</tr>
</table>
</body>
</html>
|
ประวัติการแก้ไข 2011-09-12 17:39:56
|
|
|
|
Date :
2011-09-12 17:38:17 |
By :
l3ankkiZ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|