javascript - 过滤数据列表输入
问题描述
我有两个下拉列表输入,它们都来自 datalist,我希望根据用户选择的输入来过滤其他输入以仅显示相关结果。
我正在将数据从 python 渲染回 HTML 页面
数据包含公司名称和银行帐号,
所以我想根据用户选择的公司只向所选公司显示相关帐户
<form id="the_form" method="POST">
{% csrf_token %}
From:
<input name="start_date" class="datepicker" type="date" value={{start_date}}/>
To:
<input name="end_date" class="datepicker" type="date" value={{end_date}}/>
<input type="text" list='List_of_Companies' data-search-in="Company" id="Input1" name="Companyname" placeholder="Choose a Company" value="{{ Company}}"/>
<input type="text" list='List_of_Accounts' data-search-in="Account" id="Input2" name="Accountname" placeholder="Choose an Account ID" value="{{ Account_Id}}"/>
<br> <br>
<button name="action" type="submit" id="showccounts" value="show">Show</button>
<button name="action" type="submit" value="download">Download</button>
<datalist id="List_of_Companies">
<select id="filenamelist" size="5" class="select">
{% for Company in info_list %}
<option value="{{ Company.3 }}">{{ Company.3 }}</option>
{% endfor %}
</select>
</datalist>
<datalist id="List_of_Accounts">
<select id="filenamelist" size="5" class="select">
{% for Company in info_list %}
<option value="{{ Company.0 }}">{{ Company.3 }}</option>
{% endfor %}
</select>
</datalist>
</form>
{% load staticfiles %}
<div id="loading" style="width:300px;height:300px;display:table-cell; vertical-align:middle; text-align:center">
<img src="{% static "app/images/Loading_icon.gif" %}" style="margin:auto">
</div>
<table id="theTable" hidden>
<thead>
<tr>
{% for c in columns %}
<th>{{ c }}</th>
{% endfor %}
</tr>
</thead>
<tbody>
{% for r in rows %}
<tr>
{% for c in r %}
<td>{{ c }}</td>
{% endfor %}
</tr>
{% endfor %}
</tbody>
</table>
{% endblock %}
{% block scripts %}
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.15/css/jquery.dataTables.min.css">
<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.15/js/jquery.dataTables.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.1/jquery-ui.min.js"></script>
解决方案
推荐阅读
- wordpress - 如何设置重定向到所需的网站文本版本?
- java - 使用 Transfer-Encoding 改造客户端和响应:chunked
- php - 如何匹配正则表达式中的文本
- php - 如何从 php 中自动生成的 url 获取 json 值
- python - 如何从自身中减去列表的一部分?
- javascript - 更新Javascript HTML的多个依赖下拉列表
- python - 使用 tflearn 加载 keras 模型
- c# - 如何编写以 ref 字符串作为参数的托管 C# dll 的 C++ 包装器
- android - 如何以编程方式显示横幅广告
- git - 在存储库中管理辅助数据的最佳方式是什么?