如何从htmlinpu更新flask中的整型字段

2024-10-03 11:18:45 发布

您现在位置:Python中文网/ 问答频道 /正文

这是我的UI我想在单击+按钮时更新字段:

this is my UI I want to update the field when I click on +

我想用flask制作一个类似google表单的应用程序,我创建了一个输入类型来添加一个新的表单字段(目前不是表单字段)。我想在点击输入时更新字段的编号。在

当我点击输入时,我正在发送一个post请求。如果我正在更新我的域,那么我正在检查我的域。但它只更新了一次。在

{cd2}

class Abform(FlaskForm):
    name = StringField('Name', validators=[DataRequired(), Length(min=2, max=20)])
    count = IntegerField('Count',default=1)
    submit = SubmitField('Submit')


@app.route("/home",methods=['POST','GET'])
def home():
    form=Abform()
    if request.method=='POST':
        form.count.data+=1
     list_type= ['int', 'string', 'text', 'boolean']
    return render_template('home.html', list_type=list_type,form=form)

home.html

^{pr2}$

我希望当我点击按钮(输入类型),这是HTML文件的第二行,我得到另一个字段。在


Tags: formuiflask表单类型homehtmltype