【发布时间】:2020-01-08 17:46:17
【问题描述】:
我有一个带有搜索栏和一些复选框的网站,这些将变量添加到 url:
term = "test"
variable1=1
url/search?term=test&variable1=1
然后,在搜索完成后,我在页面左侧有另一个表单,其中包含一些其他复选框和另一个搜索按钮。我希望该按钮在单击时使用旧的搜索词和变量运行另一个搜索,但添加了新的搜索
othervariable=1
url/search?term=test&variable1=1&othervariable=1
我尝试了其他线程的一些建议,但第二个搜索按钮似乎只将变量添加到 url
url/othervariable=1
这不起作用
第一种形式:
<form id="search_form" method="get" name="search">
<div class="input-group row" style="width: 40vw ">
{% if termo %}
<input style="border-radius: 0; background-color: rgba(255,255,255,0.8);" type="text" maxlength="1800" id="input_text" name="termo_busca" class="form-control" value="{{ termo }}"/>
{% else %}
<input style="border-radius: 0; background-color: rgba(255,255,255,0.8);" type="text" name="termo_busca" class="form-control" placeholder="Digite o termo que deseja pesquisar"/>
{% endif %}
<div class="input-group-btn">
<button style="background-color: #4A9FFF; border-color: #4A9FFF; cursor: pointer; border-radius: 0; padding: 0.85rem 1.05rem; font-size: 1.5rem; line-height: 1.25;" onclick="changeFlag()" type="submit" class="btn btn-primary btn-md" value="Buscar">
<i class="fa fa-search"></i>
</button>
</div>
</div>
<div class="input-group row" style="width: 44vw">
<!-- <label style="font-size: 12px;">Cortes :</label> -->
<label class="checkbox-inline" style="font-size: 11px; background-color: rgba(255,255,255,0.0);">
<input type="checkbox" name="recursal" value="1" {% if "recursal" in courts %} checked {% else %} {% endif %}> Recursal
</label>
<label class="checkbox-inline" style="font-size: 11px; background-color: rgba(255,255,255,0.0);">
<input type="checkbox" name="constitucional" value="1" {% if "constitucional" in courts %} checked {% else %} {% endif %} > Constitucional
</label>
<label class="checkbox-inline" style="font-size: 11px; background-color: rgba(255,255,255,0.0);">
<input type="checkbox" name="reclamacao" value="1" {% if "reclamacao" in courts %} checked {% else %} {% endif %} > Reclamacao
</label>
<label class="checkbox-inline" style="font-size: 11px; background-color: rgba(255,255,255,0.0);">
<input type="checkbox" name="habeas_corpus" value="1" {% if "habeas_corpus" in courts %} checked {% else %} {% endif %} > Habeas Corpus
</label>
<label class="checkbox-inline" style="font-size: 11px; background-color: rgba(255,255,255,0.0);">
<input type="checkbox" name="mandado_seguranca" value="1" {% if "mandado_seguranca" in courts %} checked {% else %} {% endif %} > Mandado Seguranca
</label>
<label class="checkbox-inline" style="font-size: 11px; background-color: rgba(255,255,255,0.0);">
<input type="checkbox" name="penal_original" value="1" {% if "penal_original" in courts %} checked {% else %} {% endif %} > Penal Original
</label>
<label class="checkbox-inline" style="font-size: 11px; background-color: rgba(255,255,255,0.0);">
<input type="checkbox" name="outros" value="1" {% if "outros" in courts %} checked {% else %} {% endif %} > Outros
</label>
<!-- <label class="checkbox-inline" style="font-size: 11px; background-color: rgba(255,255,255,0.0);">
<input type="checkbox" name="todos" value="1" {% if todos == None %} {% else %} checked {% endif %} checked> Todos
</label> -->
</div>
{% if total %}
<strong style="font-size: 13px;"></strong>
{% elif termo %}
<strong style="font-size: 13px;">Não foram encontradas decisões relacionadas ao termo {{ termo }}.</strong> <br/><br/>
{% endif %}
</form>
第二种形式:
<form id="diogo_form" method="get" name="search" ; background-color: rgba(255,255,255,0.0);">
<div class="dropdown" data-control="checkbox-dropdown">
<label class="dropdown-option">
<input type="checkbox" name="selecone" value="1" {% if "selecone" in decision_results %} checked {% else %} {% endif %}/>
selecone
</label>
<label class="dropdown-option">
<input type="checkbox" name="Selection Two" value="1" {% if "Selection Two" in decision_results %} checked {% else %} {% endif %}/>
Selection Two
</label>
<label class="dropdown-option">
<input type="checkbox" name="Selection Three" value="1" {% if "Selection Three" in decision_results %} checked {% else %} {% endif %}/>
Selection Three
</label>
<label class="dropdown-option">
<input type="checkbox" name="Selection Four" value="1" {% if "Selection Four" in decision_results %} checked {% else %} {% endif %}/>
Selection Four
</label>
<label class="dropdown-option">
<input type="checkbox" name="Selection Five" value="1" {% if "Selection Five" in decision_results %} checked {% else %} {% endif %}/>
Selection Five
</label>
</div>
<div class="input-group-btn">
<button style="background-color: #4A9FFF; border-color: #4A9FFF; cursor: pointer; border-radius: 0; padding: 0.85rem 1.05rem; font-size: 1.5rem; line-height: 1.25;" onclick="changeFlag()" type="submit" class="btn btn-primary btn-md" value="Buscar">
<i class="fa fa-search"></i>
</button>
</div>
</form>
【问题讨论】:
-
您可以将查询字符串中的值分配给表单中的 html 隐藏输入...这样它们将第二次通过
-
是的,
?左侧的 URL 部分是位置,提交第二个 GET 表单将忽略其他所有内容。
标签: javascript jquery html forms checkbox