[英]How can I change a select option value when I change the value of another select option in AngularJS?
[英]How can i add value in Option Select?
我有一个textarea文本“ ez.aaaa.value”,我想输入一个文本,当我选择option时,会自动重定向到google.com/search?tbm=isch&q= +(((value textarea)))
范例:
........
<option value="href='http://www.google.com/search?tbm=isch&q=' + ez.aaaa.value">google search</option>
........
这应该做。
location.href
是用于链接的内容。
this
是指select和selectedIndex
返回所选选项的编号。
var sel = document.getElementById('mysel'), query = document.getElementById('myquery'); sel.addEventListener('change' , function() { console.log(this.options[this.selectedIndex].value + query.value); // this would be how to link below // location.href = this.options[this.selectedIndex].value + query.value; });
<input type='text' id="myquery"> <select id="mysel"> <option>SELECT ONE</option> <option value="http://google.com?q=">google</option> <option value="http://bing.com?q=">bing</option> </select>
在您的option
之外添加具有ID的select
,然后尝试这种方式
JS
var e = document.getElementById("select-menu");
var strUser = e.options[e.selectedIndex].value;
console.log(strUser);
的HTML
<select id="select-menu">
<option value="href='http://www.google.com/search?tbm=isch&q=' + ez.aaaa.value">google search 1</option>
<option value="href='http://www.google.com/search?tbm=isch&q=' + ez.aaaa.value" selected="selected">google search 2</option>
</select>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.