我有一个下拉列表,它将有多个函数。
**上述两项操作都可以用当前代码完成。我的问题是允许下拉列表也通过onclick
打开modals。
我使用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 ✚</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>
发布于 2019-05-06 04:19:23
尝尝这个,
<select class="form-control noform" onchange="doAction(this.value);">
<option selected="true" disabled="disabled">
<h6>ACTIONS ✚</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中,您需要做一些重定向和打开模式的尝试和错误操作。
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;
}
}
https://stackoverflow.com/questions/55998647
复制相似问题