执行搜索后从显示中排除隐藏的输入值

时间:2018-07-06 05:01:05

标签: javascript forms concatenation

我正在使用javascript连接字符串以在shopify的搜索结果中省略产品。 我想知道是否有一种方法可以防止执行搜索后隐藏的输入值显示在输入中?

类似value="{{ search.terms | escape }} -= q"的东西吗?预先感谢您的帮助!

function SubmitForm() {
  var myVendor = "vendor:vendorname";
  var q_Input = document.getElementById("search_form").elements.namedItem("q_input").value;
  document.getElementById("q").value = q_Input + " " + myVendor;
  return true;
}
<div class="navigation__search{% if animate %} navigation__entrance-animation{% endif %}">
  <form id="search_form" action="/search" onsubmit="SubmitForm();" name="search" method="get" role="search"><input type="hidden" name="view" value="myvalue" /><input type="hidden" name="type" value="product" />
    <div class="input-group--underline">
      <input class="input-group__field" type="text" name="q_input" id="q_input" value="{{ search.terms | escape }}" placeholder="{{ 'general.search.placeholder' | t }}" aria-label="{{ 'general.search.placeholder' | t }}" {% if disableTab %} tabindex="-1" {%
        endif %}>
      <input type="hidden" id="q" name="q" value="" />
      <div class="input-group__btn">
        <button type="submit" class="btn btn--clear btn--square" {% if disableTab %} tabindex="-1" {% endif %}>
          {% include 'icon-search' %}
          <span class="icon__fallback-text">{{ 'general.search.submit' | t }}</span>
        </button>
      </div>
    </div>
  </form>
</div>

0 个答案:

没有答案