加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – 我希望默认选中一个复选框,[复制]

发布时间:2020-12-13 21:56:15 所属栏目:PHP教程 来源:网络整理
导读:参见英文答案 How can I set the default value for an HTML select element?????????????????????????????????????22个 我什么时候会更新我的学期,默认情况下会选中一个复选框来检查它是怎么可能的? select name="semester" option value=""Select Semeste
参见英文答案 > How can I set the default value for an HTML <select> element?????????????????????????????????????22个
我什么时候会更新我的学期,默认情况下会选中一个复选框来检查它是怎么可能的?

<select name="semester">
  <option value="">Select Semester</option>
  <option value="1">Semester 1</option>
  <option value="2">Semester 2</option>
  <option value="3">Semester 3</option>
</select>

解决方法

请试试这个

<select name="semester">
            <option value="">Select Semester</option>
            <option value="1" <?php if($data['semester']==1){echo 'selected';}?>>Semester 1</option>
            <option value="2" <?php if($data['semester']==2){echo 'selected';}?>>Semester 2</option>
            <option value="3" <?php if($data['semester']==3){echo 'selected';}?>>Semester 3</option>
</select>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读