Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/310.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/88.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从flask html到python获取值_Python_Html_Flask_Infragistics_Ignite Ui - Fatal编程技术网

从flask html到python获取值

从flask html到python获取值,python,html,flask,infragistics,ignite-ui,Python,Html,Flask,Infragistics,Ignite Ui,下面给出了我使用python创建flask服务器的html代码。我来了 只选中复选框SelectCombo,在FlaskUI中选中复选框后,我想在单击任何flask按钮时用python打印这些值。 如何在python中获取和打印该值? 如果有人知道答案,请帮助我 多谢各位 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>

下面给出了我使用python创建flask服务器的html代码。我来了 只选中复选框SelectCombo,在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>

所以我放置
导入pdb;pdb.set_trace()
就在
打印(val)
代码之前,并找到

-> print(val)
(Pdb) p request.form
ImmutableMultiDict([('date1', ''), ('date2', ''), ('min1', ''), ('min2', ''),
('min3', ''), ('min4', ''), ('min5', ''), ('min6', ''), ('min7', ''), ('min8', ''),
('min9', ''), ('min10', ''), ('min11', ''), ('min12', ''), ('max1', ''), ('max2', ''),
('max3', ''), ('max4', ''), ('max5', ''),('max6', ''), ('max7', ''), ('max8', ''),
('max9', ''), ('max10', ''), ('max11', ''), ('max12', '')])
所以我们看到checkboxSelectCombo不是表单的一部分。右键单击下拉框并选择Inspect,检查生成的HTML并查找

<input type="hidden" class="ui-igcombo-hidden-field" value="SAN FP Equity">


啊,这个元素没有名字。您的问题似乎在javascript中,而不是烧瓶。

什么是“烧瓶按钮”?我看不出你的代码中Flask的功能在哪里?在这个代码中,我没有给出按钮。在这里,我只给出了主代码,在我的原始代码中,我给出了带有python后端代码的使用输入标记的按钮?这里的代码都与Flask无关。HTML按钮也与Flask无关。我想你误解了什么是Flask,作为一个web框架。我编辑了代码部分并给出了完整的代码。@Roganjosh很抱歉听起来很迂腐,但我认为你没有。您仍然没有包含任何Flask代码(最后的一小段代码依赖于Jinja2)。您的要求要求我们构建后端,然后创建与之通信所需的表单。除非我遗漏了什么,否则这不是你要求的琐碎工作。我在python中工作,我对javascript一无所知,那么checkboxSelectCombo是javascript代码吗?我不能将其中的选定值获取到python吗?是否需要更改复选框选择的代码@Frustradi不需要做很多javascript,也不需要使用创建comboBox输入项的igCombo。底线是,除非它创建了一个带有name属性的输入项,否则POST请求不会发送它。查看供应商文档和示例,了解如何指定name属性。这不是Python或Flask的问题。只需通过公开的选项为组合提供一个名称:
<input type="hidden" class="ui-igcombo-hidden-field" value="SAN FP Equity">