PDA

View Full Version : نمایش اطلاعات در لیست باکس



.fatemeh
سه شنبه 21 دی 1389, 19:56 عصر
من سه تا لیست باکس دارم، که اطلاعات هر کدوم از بانک می یاد و نمایش داده می شه.
می خوام وقتی در اولین لیست باکس ، یکی از موارد رو انتخاب کرد، موارد مربوط به آن در لیست باکس دوم ظاهر بشه و وقتی یکی از موارد رو در لیست باکس دوم انتخاب کرد ، موارد مربوط به آن در لیست باکس سوم نمایش داده بشه.
کدش رو نوشتم ، در مورد دو لیست باکس اول کار می کنه ولی لیست باکس سوم مشکل داره.
کدش رو می زارم.
لطفا هرکسی می تونه کمک کنه اگر مشکلی در کدنویسی هست،حلش کنم
ممنون
صفحه 1:

<html>
<head>
<title>Untitled Document</title>
<script type="text/javascript">
function result(value){
if(value.length==0){
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}

xmlhttp.onreadystatechange=function(){
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("result").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","t2.php?id="+value,true);
xmlhttp.send(null);
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="css.css" rel="stylesheet" type="text/css">
</head>
<body>
<?php
$q="select id_s,name from section";
$re=mysql_query($q);
?>
<div align="center">
<p>
<select name="number_query" class="text" onchange="result(this.value);">
<?php
for($i=0;$i<mysql_num_rows($re);$i++)
{
$f=mysql_fetch_array($re);
?>
<option value="<?php echo $f['id_s'];?>"><?php echo $f['name'];?></option>
<?php }?>
</select>
</p>
</div>
<p>&nbsp; </p>
<div align="center" id="result">
<select name="cat" class="text" id="cat">
<option>.................</option>
</select>
</div>
<p>
</body>
</html>

صفحه 2:

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript">
function result1(value){
if(value.length==0){
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}

xmlhttp.onreadystatechange=function(){
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("result1").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","t3.php?p="+value,true);
xmlhttp.send(null);
}
</script>
</head>
<body>
<?php
$id=$_GET['id'];
$q="select * from category where id_s=$id";
$re=mysql_query($q);
?>
<select name="select" class="text" onchange="result1(this.value);">
<?php for($i=0;$i<mysql_num_rows($re);$i++)
{
$f=mysql_fetch_array($re);
if($id==$f['id_s'])
?>
<option value="<?php echo $f['id_c'];?>"><?php echo $f['name'];?></option>
<?php }?>
</select>
<p>
<p>&nbsp;</p>
<div align="center" id="result1">
<select name="cat" class="text" id="cat">
<option>.................</option>
</select>
</div>
</body>
</html>

صفحه 3:

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<?php
$p=$_GET['p'];
$q="select * from group where id_c=$p";
$re=mysql_query($q);
?>
<select class="text" >
<?php
for($i=0;$i<mysql_num_rows($re);$i++)
{
$f=mysql_fetch_array($re);
if($id1==$f['id_c'])
?>
<option ><?php echo $f['name'];?></option>
<?php }?>
</select>

</body>
</html>