Html 自动填写表格
我想使用数量和项目价格自动更新我的总金额字段?有没有任何方法可以使用没有javascript的烧瓶?我希望在键入数量和项目价格时更新总金额Html 自动填写表格,html,flask,autocomplete,flask-wtforms,Html,Flask,Autocomplete,Flask Wtforms,我想使用数量和项目价格自动更新我的总金额字段?有没有任何方法可以使用没有javascript的烧瓶?我希望在键入数量和项目价格时更新总金额 class ItemForm(FlaskForm): item = StringField('Item') quantity=IntegerField('Quantity') item_price=IntegerField('Item Price') class Meta: csrf = False clas
class ItemForm(FlaskForm):
item = StringField('Item')
quantity=IntegerField('Quantity')
item_price=IntegerField('Item Price')
class Meta:
csrf = False
class CostumerForm(FlaskForm):
costumer_name=StringField('Costumer Name: ')
item_detail = FieldList(FormField(ItemForm), min_entries=1)
add_item = SubmitField(label='Add Item')
remove_item = SubmitField(label='Remove Item')
total_amount=IntegerField('Total Amount')
paid_amount=IntegerField('Paid Amount')
submit=SubmitField('Submit')
proceed=SubmitField('Proceed')
@app.route('/costumer',methods=['GET','POST'])
@login_required
def costumer():
form=CostumerForm()
if form.add_item.data:
form.item_detail.append_entry()
return render_template('costumer.html', form=form)
if form.remove_item.data:
form.item_detail.pop_entry()
return render_template('costumer.html', form=form)
if form.validate_on_submit():
item=breakdown(form.item_detail.data)[0]
quantity=breakdown(form.item_detail.data)[1]
item_price=breakdown(form.item_detail.data)[2]
amount=breakdown(form.item_detail.data)[3]
total_amount=breakdown(form.item_detail.data)[4]
remaning_amount=total_amount-form.paid_amount.data
sales=Costumer(admin_id=current_user.id,item_id=item,
costumer_name=form.costumer_name.data,quantity=quantity,
item_price=item_price,amount=amount,total_amount=total_amount,
paid_amount=form.paid_amount.data,remaning_amount=remaning_amount)
db.session.add(sales)
db.session.commit()
return redirect(url_for('salesvoucher'))
return render_template('costumer.html',form=form)
costumer.html
销售额 {{form.hidden_tag()}} {{form.customer_name.label}{{form.customer_name(class='form-control input group-ig',placeholder='customer name')} 项目 量 项目价格 {form.item_detail%}中字段的% {%f在字段%} {{f(class='form-control')} {%endfor%} {%endfor%} {{form.add_项(class='btn btn primary')}{{{form.remove_项(class='btn btn danger')}} {{form.procedure(class='btn btn primary')}
``` 不可能。即使只在前端更新,也必须使用javascript