下面给出了html代码,我使用python创建了flask服务器。我来了 只使用checkboxSelectCombo,在FlaskUI中选中复选框后,我想在单击任何flask按钮时用python打印这些值。 如何在python中获取和打印这些值? 如果有人知道答案,请帮帮我。在
谢谢你
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>OPTIMIZATION</title>
<title></title>
<!-- Ignite UI Required Combined CSS Files -->
<link href="http://cdn-na.infragistics.com/igniteui/2018.1/latest/css/themes/infragistics/infragistics.theme.css" rel="stylesheet" />
<link href="http://cdn-na.infragistics.com/igniteui/2018.1/latest/css/structure/infragistics.css" rel="stylesheet" />
<script src="http://ajax.aspnetcdn.com/ajax/modernizr/modernizr-2.8.3.js"></script>
<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="http://code.jquery.com/ui/1.11.1/jquery-ui.min.js"></script>
<!-- Ignite UI Required Combined JavaScript Files -->
<script src="http://cdn-na.infragistics.com/igniteui/2018.1/latest/js/infragistics.core.js"></script>
<script src="http://cdn-na.infragistics.com/igniteui/2018.1/latest/js/infragistics.lob.js"></script>
</head>
<style>
table {
font-family: arial, sans-serif;
border-collapse: collapse;
background-color: #dddddd;
width: 100%;
}
td, th {
border: 1px solid #dddddd;
text-align: left;
padding: 1px;
}
</style>
<body bgcolor="#a9d284">
<img src="/static/images/logo.gif" alt="Related Book 1" width="300" height="80" align="right">
<script src="/static/scripts.js" charset="utf-8"></script>
<h1>PORTFOLIO OPTIMIZATION</h1>
<style>
.combo-label {margin-bottom:.5em;}
</style>
<form method="POST" action="">
<h4 class="combo-label">SELECT THE STOCK OPTIONS</h4>
<div id="checkboxSelectCombo"></div>
<br><br>
<h4>SELECT THE INPUT DATE</h4>
<input type="date" name="date1" placeholder="Start date">
<input type="date" name="date2" placeholder="End date">
<br><br>
<h4>ENTER CONSTRAINTS CRITERIA</h4>
<table>
<tr>
<th> </th>
<th>Cheap</th>
<th>Moderate</th>
<th>Expensive</th>
<th>PUT</th>
<th>CALL</th>
<th>Not Recommended</th>
<th>Highly Liquid</th>
<th>Moderately Liquid</th>
<th>Less Liquid</th>
<th>MPO</th>
<th>PO</th>
<th>LPO</th>
</tr>
<tr>
<td>Group_Min</td>
<td class="td"><input type="text" name="min1"/></td>
<td class="td"><input type="text" name="min2" /></td>
<td class="td"><input type="text" name="min3"/></td>
<td class="td"><input type="text" name="min4"/></td>
<td class="td"><input type="text" name="min5"/></td>
<td class="td"><input type="text" name="min6"/></td>
<td class="td"><input type="text" name="min7"/></td>
<td class="td"><input type="text" name="min8"/></td>
<td class="td"><input type="text" name="min9"/></td>
<td class="td"><input type="text" name="min10"/></td>
<td class="td"><input type="text" name="min11"/></td>
<td class="td"><input type="text" name="min12"/></td>
</tr>
<tr>
<td>Group_Max</td>
<td class="td"><input type="text" name="max1"/></td>
<td class="td"><input type="text" name="max2"/></td>
<td class="td"><input type="text" name="max3"/></td>
<td class="td"><input type="text" name="max4"/></td>
<td class="td"><input type="text" name="max5"/></td>
<td class="td"><input type="text" name="max6"/></td>
<td class="td"><input type="text" name="max7"/></td>
<td class="td"><input type="text" name="max8"/></td>
<td class="td"><input type="text" name="max9"/></td>
<td class="td"><input type="text" name="max10"/></td>
<td class="td"><input type="text" name="max11"/></td>
<td class="td"><input type="text" name="max12"/></td>
</tr>
</table>
<br><br>
<input type="submit" value="GET RESULTS">
</form>
<script>
var colors = [
{ Name: "FP FP Equity" },
{ Name: "SAN FP Equity" },
{ Name: "NOK1V FH Equity" },
{ Name: "SAN SQ Equity" },
{ Name: "EOA GY Equity" },
{ Name: "SIE GY Equity" },
{ Name: "ENI IM Equity" },
{ Name: "UC IM Equity" },
{ Name: "INGA NA Equity" },
{ Name: "TEF SQ Equity" },
{ Name: "BNP FP Equity" },
{ Name: "BBVA SQ Equity" },
{ Name: "ALV GY Equity" }
];
$(function () {
$("#singleSelectCombo").igCombo({
width: 300,
dataSource: colors,
textKey: "Name",
valueKey: "Name",
dropDownOnFocus: true,
dropDownOrientation: "bottom"
});
$("#multiSelectCombo").igCombo({
width: 300,
dataSource: colors,
textKey: "Name",
valueKey: "Name",
multiSelection: {
enabled: true
},
dropDownOrientation: "bottom"
});
$("#checkboxSelectCombo").igCombo({
width: 300,
dataSource: colors,
textKey: "Name",
valueKey: "Name",
multiSelection: {
enabled: true,
showCheckboxes: true
},
dropDownOrientation: "bottom"
});
});
</script>
</body>
</html>
<!doctype html>
<title>Simple tables</title>
<link rel=stylesheet type=text/css href="{{ url_for('static', filename='style.css') }}">
<div class=page>
<h2>OPTIMIZED VALUES</h2>
{% for table in tables %}
<h3>{{titles[loop.index]}}</h3>
{{ table|safe }}
{% endfor %}
</div>
Python后端代码
^{pr2}$
所以我把
import pdb; pdb.set_trace()
放在你的print(val)
代码之前,然后发现所以我们看到checkboxSelectCombo不是表单的一部分。右击drop box并选择Inspect,我检查生成的HTML并找到
^{pr2}$啊,这个元素没有名字。你的问题似乎出在javascript上,而不是烧瓶。在
相关问题 更多 >
编程相关推荐