gpt4 book ai didi

javascript - 下拉列表中的多项操作

转载 作者:行者123 更新时间:2023-11-28 02:23:20 26 4
gpt4 key购买 nike

我有一个具有多种功能的下拉菜单。

  • “更新”会将您带到更新信息的页面
  • “导出表单”会将您带到导出表单的页面

**以上两个操作都可以用当前代码完成。我遇到的问题是允许下拉菜单也通过 onclick 打开模式。

  • “删除类(class)”打开模式
  • “查看评论”打开模式

我使用 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>

最佳答案

试试这个,

<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:

In js you need to do some try and error thing for redirection and open modal

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;
}
}

关于javascript - 下拉列表中的多项操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55998647/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com