คลิกที่list box เพื่อเลือกชื่อแต่พอเลือกแล้วชื่อแล้วชื่อที่เลือกไม่ชึ้นใน list box เพื่อโชว์ชื่อว่าส่งไปหาตามชื่อที่ได้เลือก แต่กลับส่งค่าตามชื่อไปได้ค่ะ
Code (C#)
<form id="form1" name="form1" method="post" action="saves.php">
<?
$status=$_SESSION['status'];
$id1=$_SESSION['id_a'];
?>
<p align="center">การให้คำปรึกษา</p>
<table width="528" border="0" align="center">
<tr>
<th width="114" scope="col"><div align="right">หัวข้อเรื่อง:</div></th>
<th colspan="2" scope="col"><div align="left">
<input name="head" type="text" id="head" size="40" />
</div></th>
</tr>
<tr>
<td> </td>
<td colspan="2"> </td>
</tr>
<tr>
<td><div align="center"><strong>รายละเอียด:</strong></div></td>
<td colspan="2"><textarea name="detail" id="detail" cols="40" rows="5"></textarea></td>
</tr>
<tr>
<td> </td>
<td colspan="2"> </td>
</tr>
<?php if ($row_t['status']=='1') { ?>
<? //if (status=='1') { ?>
<tr>
<td height="27"><div align="center"><strong>หมุ่เรียน:</strong></div></td>
<td width="154"><label>
<select name="a" id="a" title="<?php echo $row_rs_class['name_class']; ?>" onChange = "ListRoom(this.value)" >
<?php
do {
?>
<option value="<?php echo $row_rs_class['name_class']?>"><?php echo $row_rs_class['name_class']?></option>
<?php
} while ($row_rs_class = mysql_fetch_assoc($rs_class));
$rows = mysql_num_rows($rs_class);
if($rows > 0) {
mysql_data_seek($rs_class, 0);
$row_rs_class = mysql_fetch_assoc($rs_class);
}
?>
</select>
</label>
<?php
do {
?>
</td>
<option value="<?php echo $row_rs_class['name_class']?>"<?php if (!(strcmp($row_rs_class['name_class'], $row_a['class_']))) {echo "selected=\"selected\"";} ?>></option>
<?php
}
while ($row_rs_class = mysql_fetch_assoc($rs_class));
$rows = mysql_num_rows($rs_class);
if($rows > 0) {
mysql_data_seek($rs_class, 0);
$row_rs_class = mysql_fetch_assoc($rs_class);
}
?>
</tr>
<tr>
<td><div align="center"><strong>ถึงนักศึกษาในที่ปรึกษา:</strong></div></td>
<td colspan="2"><label>
<select name="id_stu" id="id_stu" onChange = "ListRoom(this.value)"/>
<option value="<?=$id_stu?>">
<? if($id_stu){echo"$id";}else if(!$id_stu){echo"เลือก";}?>
</option>
</select>
</label></td>
</tr>
<? } ?>
<tr>
<td> </td>
<td><?php if ($row_t['status']=='0') { echo $row_teach['name_tech'];} ?></td>
</tr>
<tr>
<td> </td>
<td colspan="2"><input type="submit" name="button" id="button" value="ส่งข้อมูล" /></td>
</tr>
</table>
<br>
<?
/* ==========================================================================================*/
?>
<script language="javascript" type="text/javascript">
function setage()
{
var selectList = document.frmselect("name");
for (i=0;i<selectList.options.length;i++)
{
selectList.removeChild(selectList.options.item(i));
}
var index_name=document.frmselect.name.selectedIndex;
document.frmselect.age.selectedIndex=index_name;
}
</script>
</form>
<script>
function ListRoom(SelectValue)
{
form1.id_stu.length = 0
//*** Insert null Default Value ***//
var myOption = new Option('','')
form1.id_stu.options[form1.id_stu.length]= myOption
<?
$intRows = 0;
$strSQL = "SELECT * FROM adv_data ";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$intRows = 0;
while($objResult = mysql_fetch_array($objQuery))
{
$intRows++;
?>
x = <?=$intRows;?>;
var mySubList = new Array();
var strID = <?=$objResult["id"];?>;
var strName = "<?=$objResult["fname"];?>";
var strLastName = "<?=$objResult["lname"];?>";
var status = "<?=$objResult["status"];?>";
mySubList[x,0] = strID;
mySubList[x,1] = strName;
mySubList[x,2] = strLastName;
mySubList[x,3] = status;
if (mySubList[x,3] == 0){
var myOption = new Option(mySubList[x,1], mySubList[x,2])
form1.id_stu.options[form1.id_stu.length]= myOption
}
<?
}
?>
}
</script>
Tag : PHP, MySQL, JavaScript
Date :
2012-07-10 07:36:10
By :
pangcs
View :
886
Reply :
1
รูปที่1
รูปที่2
Date :
2012-07-10 07:39:24
By :
pangcs
Load balance : Server 04