猿问

下拉菜单中的多个动作

我有一个下拉菜单,它将具有多种功能。

  • “更新”将您带到页面以更新信息

  • “导出表单”将您带到页面以导出表单

**以上两项操作都可以使用当前代码完成。我遇到的问题是允许下拉菜单也通过来打开模式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>


蝴蝶刀刀
浏览 186回答 1
1回答

哆啦的时光机

试试这个,<select class="form-control noform" onchange="doAction(this.value);">&nbsp; <option selected="true" disabled="disabled">&nbsp; &nbsp; <h6>ACTIONS &#10010;</h6>&nbsp; </option>&nbsp; <option value="update">UPDATE</option>&nbsp; <option value="exportForm">EXPORT FORM</option>&nbsp; <option value="deletCourse">DELETE COURSE</option>&nbsp; <option value="viewComments">VIEW COMMENTS</option></select>JS:在js中,您需要为重定向和打开模式做一些尝试和错误的事情function doAction(value){&nbsp; switch (value) {&nbsp; &nbsp; &nbsp; case "update":&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //edit_course?person_id=<?php echo htmlentities ($row['id']) ?>&session_id=<?php echo $_GET['session_id'] ?>&operation=edit&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //here you can do your update redirection&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;&nbsp; &nbsp; &nbsp; case "exportForm":&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //export?person_id=<?php echo htmlentities ($row['id']) ?>&session_id=<?php echo $_GET['session_id'] ?>&operation=edit&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //here you can do your export redirection&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;&nbsp; &nbsp; &nbsp; case "deletCourse":&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; deleteCourse();//here you can open your modal&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;&nbsp; &nbsp; &nbsp; case "viewComments":&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; openModal();//here you can open your modal&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;&nbsp; }}
随时随地看视频慕课网APP
我要回答