这是我的Blog
我在主页上添加了多标签搜索。
但是当我从菜单中选择绿色和灰色标签并点击过滤器后,它会重定向到example.com/search/?q=label:blue|label:black 页
但是想要将标签绿色和灰色重定向到标签:绿色|标签:灰色
以下是代码
<!doctype html>
<div class="tabs-outer">
<div class="tabs-cap-top cap-top">
<div class="cap-left"></div>
<div class="cap-right"></div>
</div>
<div class="fauxborder-left tabs-fauxborder-left">
<div class="fauxborder-right tabs-fauxborder-right"></div>
<div class="region-inner tabs-inner">
<div class="tabs section" id="main">
<div class="widget HTML" id="HTML3">
<h2 class="title">Multi Label Search</h2>
<div class="widget-content">
<div id="multi-search">
<select id="cmbColumn" name="cmbColumn">
<option value="" />Columns
<option value="green+" />green
<option value="blue+" />blue
</select>
<select id="cmbSidebar" name="cmbSidebar">
<option value="" />Sidebars
<option value="Gray+" />Gray
<option value="black+" />black
</select>
<input onclick=" getValue() " value="Filter" type="button" />
</div>
</div>
<div class="clear"></div>
<span class="widget-item-control">
<span class="item-control blog-admin">
<a class="quickedit" href="https://www.blogger.com/rearrange?blogID=5988384389032442595&action=editWidget§ionId=main" onclick=" return _WidgetManager._PopupConfig(document.getElementById("HTML3")); " target="configHTML3" title="Edit">
<img alt="" src="http://img1.blogblog.com/img/icon18_wrench_allbkg.png" height="18" width="18" />
</a>
</span>
</span>
<div class="clear"></div>
</div>
</div>
<div class="tabs section" id="main"></div>
</div>
</div>
<div class="tabs-cap-bottom cap-bottom">
<div class="cap-left"></div>
<div class="cap-right"></div>
</div>
</div>
<script type="text/javascript">
function getValue() {
var
valcmbColumn = document.getElementById("cmbColumn").value = "green";
valcmbSidebar = document.getElementById("cmbSidebar").value = "|label:Gray";
valOutput = (valcmbColumn + valcmbSidebar);
window.open("/search/?q=label:" + valOutput, "_self");
valcmbColumn = document.getElementById("cmbColumn").value = "blue";
valcmbSidebar = document.getElementById("cmbSidebar").value = "|label:black";
valOutput = (valcmbColumn + valcmbSidebar);
window.open("/search/?q=label:" + valOutput, "_self");
}
function toggle_visibility(id) {
var e = document.getElementById(id);
if (e.style.display == "block") {
e.style.display = "none";
} else {
e.style.display = "block";
}
}
</script>
</!doctype>
&#13;
答案 0 :(得分:1)
试试这个。我认为这应该可以解决问题。我无法使用您提供的代码进行测试
function getValue() {
var valcmbColumn = document.getElementById("cmbColumn").value;
var valcmbSidebar = document.getElementById("cmbSidebar").value;
valOutput = "label:"+valcmbColumn+"|label:"+ valcmbSidebar;
window.open("/search/?q=" + valOutput, "_self");
}
让我知道它是否有效
答案 1 :(得分:0)
试试这个:
<!doctype html>
<div class="tabs-outer">
<div class="tabs-cap-top cap-top">
<div class="cap-left"></div>
<div class="cap-right"></div>
</div>
<div class="fauxborder-left tabs-fauxborder-left">
<div class="fauxborder-right tabs-fauxborder-right"></div>
<div class="region-inner tabs-inner">
<div class="tabs section" id="main">
<div class="widget HTML" id="HTML3">
<h2 class="title">Multi Label Search</h2>
<div class="widget-content">
<div id="multi-search">
<select id="cmbColumn" name="cmbColumn">
<option value="" />Columns
<option value="green" />green
<option value="blue" />blue
</select>
<select id="cmbSidebar" name="cmbSidebar">
<option value="" />Sidebars
<option value="gray" />Gray
<option value="black" />black
</select>
<input onclick=" getValue() " value="Filter" type="button" />
</div>
</div>
<div class="clear"></div>
<span class="widget-item-control">
<span class="item-control blog-admin">
<a class="quickedit" href="https://www.blogger.com/rearrange?blogID=5988384389032442595&action=editWidget§ionId=main" onclick=" return _WidgetManager._PopupConfig(document.getElementById("HTML3")); " target="configHTML3" title="Edit">
<img alt="" src="http://img1.blogblog.com/img/icon18_wrench_allbkg.png" height="18" width="18" />
</a>
</span>
</span>
<div class="clear"></div>
</div>
</div>
<div class="tabs section" id="main"></div>
</div>
</div>
<div class="tabs-cap-bottom cap-bottom">
<div class="cap-left"></div>
<div class="cap-right"></div>
</div>
</div>
<script type="text/javascript">
function getValue() {
valcmbColumn = document.getElementById("cmbColumn").value;
valcmbSidebar = document.getElementById("cmbSidebar").value;
valOutput = (valcmbColumn +"|"+ valcmbSidebar);
//window.open("/search/?q=label:" + valOutput, "_self");
alert(valOutput);
}
function toggle_visibility(id) {
var e = document.getElementById(id);
if(e.style.display == "block") {
e.style.display = "none";
} else {
e.style.display = "block";
}
}
</script>
&#13;
添加
alert()
以显示输出。