我想根据onclick表值预先选择下拉选项,同时导航到下拉选项的另一页。
下面是代码
app.py
@app.route('/userinfo',methods=["POST","GET"])
def userinfo():
result = cursor.execute("SELECT * FROM user ORDER BY id")
user= cursor.fetchall()
result1 = cursor.execute("SELECT * FROM header ORDER BY id ")
header = cursor.fetchall()
return render_template('userinfo.html', user= user, result1=result1)
userinfo.html
<div class="form-group">
<div class="cols-sm-10">
<h5>user onfo </h5>
<select name="name1" class="teamForm" id="teamDropdown" type="text" placeholder="Select projects">
{% for i in user %}
<option id="{{ i.id }}" value= "{{ i.id }}">{{ i.name }}</option>
{% endfor %}
</select>
<select name="tasks" class="teamForm2" id="teamDropdown1" type="text" method="POST">
{% for j in header %}
<option id="{{ j.id }}" value= "{{ j.header1 }}" selected>{{j.header1 }}</option>
<option id="{{ j.id }}" value= "{{ j.header2 }}">{{j.header2 }}</option>
<option id="{{ j.id }}" value= "{{ j.header3 }}" selected>{{j.header3 }}</option>
<option id="{{ j.id }}" value= "{{ j.header4 }}" selected>{{j.header4 }}</option>
{% endfor %}
</select>
</div>
</div>
index.html
<thead>
{% for row in header %}
<tr>
<th data-pk="{{row.id}}">{{row.id}}</th>
<th data-pk={{row.id}}">{{row.name}}</th>
<th data-pk="{{row.id}}">{{row.date}}</th>
<th data-pk="{{row.id}}">{{row.header1}}</th>
<th data-pk="{{row.id}}">{{row.header2}}</th>
<th data-pk="{{row.id}}">{{row.header3}}</th>
</tr>
{% endfor %}
</thead>
<tbody>
{% for row in emp %}
<tr>
<td data-pk="{{row.id}}">{{row.id}}</td>
<td data-name="name" class="name" data-type="text" data-pk="{{row.id}}">{{row.name}}</td>
<td class="under-limit" onclick="location.href='/userinfo'">{{row.task1}}<i id='{{row.id}}' class="fainfo fa fa-info-circle" title=" " aria-hidden="true"></i></td>
<td class="under-limit" onclick="location.href='/userinfo'">{{row.task2}}<i class="fatask2 fa fa-info-circle" id='{{row.id}}' title=" " aria-hidden="true"></i></td>
<td class="under-limit" onclick="location.href='/userinfo'">{{row.task3}}<i class="fatask3 fa fa-info-circle" id='{{row.id}}' title=" " aria-hidden="true"></i></td>
</tr>
{% endfor %}
{/tbody>
单击表格单元格时,根据选定的行和列,必须选择下拉选项,同时导航到另一个页面。我试着用jquery,但做不到。谁能帮我一下吗。
暂无答案!
目前还没有任何答案,快来回答吧!