我正在尝试通过选择班级和学生ID来填充学生详细信息。我正在尝试进行相互关联的下拉菜单,第一个下拉菜单将选择班级,然后第二个下拉菜单将填充该班级的学生ID。选择学生ID后,它必须生成学生详细信息。
当我选择班级下拉菜单时,第二个选择框消失。我无法在这里找出错误。我没有检查控制台,那里也没有显示任何错误。这是我的代码
这是我的html
<div class="col-xs-4">
<div class="form-group has-error"> <label class="col-md-12 control-label">Class</label>
<select name="class_id" class="form-control" required onChange="stdents_func(this.value,''); ">
<option value="">Select Class</option>
<?php
foreach($class_res as $calss) {
?>
<option value="<?php echo $calss['es_classesid'];?>" <?php if($class_id==$calss['es_classesid']){ echo ' selected="selected" ';}?>><?php echo $calss['es_classname'];?></option>
<?php } ?></select></div>
</div>
<div class="col-xs-4">
<div class="form-group has-error" id="students"> <label class="col-md-12 control-label">Select Student</label>
<select name="student_id" class="form-control" required onchange="stdents_info(this.value); ">
<option value="">Select Student</option></select></div>
</div>
<div class="col-xs-4">
<div class="form-group has-error"> <label class="col-md-12 control-label">Invoice Number</label>
<input name="invioce_no" type="text" value="<?php echo $invioce_no;?>" class="form-control" required size="8" /></div>
</div>
</div>
<?php
if(isset($class_id) && $class_id!='')
{
?>
<script>
stdents_func(<?php echo $class_id; echo $student_id;?>);
</script>
<?php
} ?>
<div class="row" id="stu_inf">
<table id="general-table" class="table table-bordered">
<tr>
<td colspan="2" align="center"><strong>Student Details</strong></td>
</tr>
<tr>
<td>Name</td>
<td><input type="text" class="form-control" name="stu_name" value="<?php echo $stu_name;?>" readonly="readonly"/></td>
</tr>
<tr>
<td>Class</td>
<td><input type="text" class="form-control" name="stu_name" value="<?php echo $stu_class;?>" readonly="readonly"/></td>
</tr>
<tr>
<td>Section</td>
<td><input type="text" class="form-control" name="stu_name" value="<?php echo $stu_sect;?>" readonly="readonly"/></td>
</tr>
<tr>
<td>Roll No</td>
<td><input type="text" class="form-control" name="stu_name" value="<?php echo $stu_roll;?>" readonly="readonly"/></td>
</tr>
<tr>
<td>Photo</td>
<td></td>
</tr>
</table>
<?php
if(isset($student_id) &&$student_id!='')
{
?>
<script>
stdents_info(<?php echo $student_id;?>);
</script>
<?php
}
?></div>
这是脚本和功能
function stdents_func(es_classesid,selval)
{
url="?pid=55&action=inventory_reports&class_id="+es_classesid+"&selval="+selval;
url=url+"&sid="+Math.random();
xmlHttp=GetXmlHttpObject(classess);
xmlHttp.open("GET", url, true);
xmlHttp.send(null);
}
function classess()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
document.getElementById("students").innerHTML=xmlHttp.responseText
}
}
function stdents_info(student_id)
{
url="?pid=55&action=students_information&stu_id="+student_id;
url=url+"&sid="+Math.random();
xmlHttp1=GetXmlHttpObject(classess1);
xmlHttp1.open("GET", url, true);
xmlHttp1.send(null);
}
function classess1()
{
if (xmlHttp1.readyState==4 || xmlHttp1.readyState=="complete")
{
document.getElementById("stu_inf").innerHTML=xmlHttp1.responseText
}
}
</script>