我有从MySQL读取的选择选项菜单。 用户将在选择用户名之前选择成绩。用户从部分选项中选择用户名,而不是从键盘输入用户名。我完成了表单选择选项。但是我无法处理“用户”部分的值。我该如何处理并放入。
<input type="text" required autocomplete="off" name="user"/>
我的选择选项代码:
<script>
window.load=$( document ).ready(function() {
$.ajax({
type:'POST',
url:'get_class.php',
success:function(html){
$('#Grade').html(html);
}
});
});
$( document ).ready(function() {
$('#Grade').on('change',function(){//change function on Grade to display all user
var GradeID = $(this).val();
if(GradeID){
$.ajax({
type:'POST',
url:'ajaxData.php',
data:'Grade_id='+GradeID,
success:function(html){
$('#user').html(html);
}
});
}else{
$('#user').html('<option value="">Select Grade first</option>');
}
});
});
</script>
</head>
<p id="profile1" style="color:red;margin-left:700px;margin-top:100px">
<b>Examples</b></p><br>
<div class="row">
<div class="col-md-1 col-sm-12" id="lable1"></div>
<div class="col-md-1 col-sm-12" id="lable1"><id="lable1">Grade</div>
<div class="col-md-2">
<select name="Grade" id="Grade"
data-live-search="true" class="chosen selectpicker form-control" required>
<option value="">Select Grade</option>
</select>
</div>
<div class="col-md-1 col-sm-12" id="lable1"><id="lable1">user</div>
<div class="col-md-2">
<select class="selectpicker form-control" name="user" id="user" autofocus="autofocus" required>
<option value="">Select an Option</option>
</select>
</div>
</div>
</br>
</div>
</div>