为了账号安全,请及时绑定邮箱和手机立即绑定

下拉菜单中的多个动作

下拉菜单中的多个动作

PHP
蝴蝶刀刀 2021-05-19 10:17:09
我有一个下拉菜单,它将具有多种功能。“更新”将您带到页面以更新信息“导出表单”将您带到页面以导出表单**以上两项操作都可以使用当前代码完成。我遇到的问题是允许下拉菜单也通过来打开模式onclick。“删除课程”打开模式“查看评论”打开模式我曾经onchange="location=this.value;"用来打开不同的页面。不过,我似乎无法弄清楚如何让双方onchange="location=this.value;"并onclick在同一个下拉菜单。我的代码:<select class="form-control noform" onchange="location=this.value;">  <option selected="true" disabled="disabled">    <h6>ACTIONS &#10010;</h6>  </option>  <option value="edit_course?person_id=<?php echo htmlentities ($row['id']) ?>&session_id=<?php echo $_GET['session_id'] ?>&operation=edit">UPDATE</option>  <option value="export?person_id=<?php echo htmlentities ($row['id']) ?>&session_id=<?php echo $_GET['session_id'] ?>&operation=edit">EXPORT FORM</option>  <option onclick="deleteCourse()">DELETE COURSE</option>  <option onclick="openModal()">VIEW COMMENTS</option></select>
查看完整描述

1 回答

?
哆啦的时光机

TA贡献1779条经验 获得超6个赞

试试这个,


<select class="form-control noform" onchange="doAction(this.value);">

  <option selected="true" disabled="disabled">

    <h6>ACTIONS &#10010;</h6>

  </option>

  <option value="update">UPDATE</option>

  <option value="exportForm">EXPORT FORM</option>

  <option value="deletCourse">DELETE COURSE</option>

  <option value="viewComments">VIEW COMMENTS</option>

</select>

JS:


在js中,您需要为重定向和打开模式做一些尝试和错误的事情


function doAction(value){

  switch (value) {

      case "update":

          //edit_course?person_id=<?php echo htmlentities ($row['id']) ?>&session_id=<?php echo $_GET['session_id'] ?>&operation=edit

          //here you can do your update redirection

          break;

      case "exportForm":

          //export?person_id=<?php echo htmlentities ($row['id']) ?>&session_id=<?php echo $_GET['session_id'] ?>&operation=edit

          //here you can do your export redirection

          break;

      case "deletCourse":

          deleteCourse();//here you can open your modal

          break;

      case "viewComments":

          openModal();//here you can open your modal

          break;

  }

}


查看完整回答
反对 回复 2021-05-28
  • 1 回答
  • 0 关注
  • 185 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信