当我提交带有“已禁用所选”选项的表单时,它显示错误
undefined index:dept(我的下拉菜单名称)“
但是如果选中它则不会显示。我怎样才能解决这个问题? 这是我的代码:
<select class="browser-default" name="dept">
<option value="DB" disabled selected>Select your department</option>
<option value="CS" <?php if(!empty($_REQUEST['dept']) && $_REQUEST['dept'] == 'CS') echo 'selected'; ?>>Computer Science</option>
<option value="EC" <?php if(!empty($_REQUEST['dept']) && $_REQUEST['dept'] == 'EC') echo 'selected'; ?>>Electronics</option>
<option value="EE" <?php if(!empty($_REQUEST['dept']) && $_REQUEST['dept'] == 'EE') echo 'selected'; ?>>Electrical</option>
<option value="AU" <?php if(!empty($_REQUEST['dept']) && $_REQUEST['dept'] == 'AU') echo 'selected'; ?>>Aeronautical</option>
</select>
这是我正在使用的变量:
$dept=$_POST['dept'];