我想防止在烧瓶中的过帐请求中清除我的表格。 这是我的代码:
predictor.html
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="static/vendor/bootstrap/css/bootstrap.min.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="static/fonts/font-awesome-4.7.0/css/font-awesome.min.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="static/vendor/animate/animate.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="static/vendor/select2/select2.min.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="static/vendor/perfect-scrollbar/perfect-scrollbar.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="static/css/util.css">
<link rel="stylesheet" type="text/css" href="static/css/main.css">
</head>
<body>
<form method="POST" id="Formid">
<div class="form-group" onsubmit="return false">
<input type="text" class="form-control input-sm" id="input" name="data_input" style="width:100%" maxlength="500"placeholder="Sepal length">
<input type="text" class="form-control input-sm" id="input" name="data_input" style="width:100%" maxlength="500"placeholder="Sepal Width">
<input type="text" class="form-control input-sm" id="input" name="data_input" style="width:100%" maxlength="500"placeholder="Petal length">
<input type="text" class="form-control input-sm" id="input" name="data_input" style="width:100%" maxlength="500"placeholder="Petal Width">
<button type="submit" class="btn btn-success" value="Submit" method="get"><i class="fa fa-search" aria-hidden="true"></i></button>
{{predictions}}
</div>
</form>
</body>
</html>
这是提交表单的示例,我得到输出,但表单值被清除
答案 0 :(得分:0)
如果我正确,您需要保留表单中其他input
字段的值,如果由于一个或多个input
(s)无效而无法处理该表单
发布请求后,将有效的input
字段的值存储在变量中,并将它们传递到value
标签的input
属性中,以便表单的输入被预先填充下次重新加载。
赞这个<input type="text" value="{{ some_variable }}" />
最初,您可以将这些变量设置为空字符串,以供用户首次输入。