如何将一个模式中下拉列表中的选定值传递到另一个模式 t 中的另一个下拉列表
How to pass a selected value in a dropdown list in one modal to another dropdown list in another modal t
我有两个下拉列表,在两种不同的模态中具有相同的值。一个在插入模式中,另一个在更新模式中。我想做的是在插入模式中传递下拉列表的选定值,当我打开更新模式时,我希望在该模式的下拉列表中选择该值。
无论如何我可以做到这一点吗?使用 Bootstrap, jquery, javascript ?
任何帮助将不胜感激。
我试过这个
var countryInsertID = document.getElementById('countryInsert'),
countryUpdate = document.getElementById('countryUpdate'),
option;
countryInsertID.onchange = function () {
option = document.createElement('option');
option.value = this.value;
option.text = this.options[this.selectedIndex].text;
countryUpdate.appendChild(option);
countryInsertID.removeChild(this.options[this.selectedIndex]);
}
听起来像是一份localStorage
的工作
var countryInsert=document.getElementById('countryInsert')
var countryUpdate=document.getElementById('countryUpdate')
countryInsert.onchange = function() {
window.localStorage.setItem('selected', countryInsert.value);
}
当您显示更新模式时
countryUpdate.value = window.localStorage.getItem('selected');
更新
如果您只是在同一页面上拥有模态,则隐藏为"引导方式",则不需要所有这些 - 只需
<script>
var countryInsert=document.getElementById('countryInsert')
var countryUpdate=document.getElementById('countryUpdate')
countryInsert.onchange = function() {
countryUpdate.value = countryInsert.value;
}
</script>
-- 在页面底部。然后国家/地区更新<select>
将始终与国家/地区同步插入<select>
相关文章:
- 想要打开从链接到另一个页面的模式弹出窗口
- Bootbox,两个模式窗口-一个在另一个之上
- 弹出模式jquery播放现有的嵌入youtube视频时,试图播放另一个
- 在简单模式中,取消单击时不会调用onClose事件..当我在simple-modal上加载另一个jquery对话框时
- 在Javascript严格模式下,您可以将参数分配给另一个变量
- 从查询传递模式 ID,以便可以在另一个查询中使用
- 如何将一个模式中下拉列表中的选定值传递到另一个模式 t 中的另一个下拉列表
- 使用在另一个服务方法中声明为模块模式的服务方法之一
- 查找字符串的单个匹配项,然后查找另一个模式的多个匹配项
- 在基础中打开另一个页面的部分显示模式
- 如何在屏幕上出现另一个引导程序时隐藏另一个引导程序的模式
- 如何创建密码登录模式,单击提交按钮,然后使用bootstrap 3打开另一个包含链接的模式
- 引用Mongoose中的另一个模式
- 匹配字符串中的一个模式但排除另一个模式的Javascript正则表达式
- 是否有更好/更短的模式来将一个对象的属性子集设置到另一个对象上?
- 如何从一个JSP页面调用另一个JSP页面中的引导模式存储
- 如何在一个引导模式从另一个模式打开滚动功能
- Emacs -用另一个字符串模式替换一些字符串模式
- 未捕获的SyntaxError:在严格模式代码中,函数只能在顶层或立即在另一个函数中声明
- MongoDB + Node.js:如何从外部文件使用另一个模式的模式