Javascript 表单提交onClick函数不在选择菜单中创建选项
函数getOption(){ var select=document.getElementById(“动态选择”); 如果(选择.options.length>0){ var option=select.options[select.selectedIndex]; 警报(“文本:+option.Text+”\n值:+option.value); }否则{ window.alert(“选择框为空”); } } 函数addOption(){ var select=document.getElementById(“动态选择”); select.options[select.options.length]=新选项('new Element','0',false,false); }Javascript 表单提交onClick函数不在选择菜单中创建选项,javascript,jquery,html,twitter-bootstrap,Javascript,Jquery,Html,Twitter Bootstrap,函数getOption(){ var select=document.getElementById(“动态选择”); 如果(选择.options.length>0){ var option=select.options[select.selectedIndex]; 警报(“文本:+option.Text+”\n值:+option.value); }否则{ window.alert(“选择框为空”); } } 函数addOption(){ var select=document.getElemen
放置自动完成的地址表单
.pac集装箱{
z指数:10000!重要;
}
运输方式
交付给*
选择配送
添加送货地址
&时代;
添加您的交付详细信息
地址
街道地址
路线
城市
陈述
邮政编码
国家
新增
接近
首先,您使用的是按钮type=“submit”
它将发回,只需使用添加新的
其次,
要么从
标记中删除模型,要么在addOption()
函数中使用return false
第三,使用jquerymap()
函数收集sideaddOption()
检查此代码:
函数getOption(){
var select=document.getElementById(“动态选择”);
如果(选择.options.length>0){
var option=select.options[select.selectedIndex];
警报(“文本:+option.Text+”\n值:+option.value);
}否则{
window.alert(“选择框为空”);
}
}
函数addOption(){
var select=document.getElementById(“动态选择”);
var newListItem=$(“#myModal input”).map(函数(){return$(this.val();}).get();
select.options[select.options.length]=新选项(newListItem,'0',false,false);
$('#myModal').modal('toggle');
返回false;
}
运输方式
交付给*
选择配送
添加送货地址
&时代;
添加您的交付详细信息
地址
var select = document.getElementById("dynamic-select");
var option = document.createElement("option");
option.text = "your text";
option.value = "your value"