I want save form data before submit to action url in flask
<form action="" method="POST">
<input type="hidden" name="PAYEE_ACCOUNT" value="U1234567">
<input type="hidden" name="PAYEE_NAME" value="Name">
<input type="text" name="PAYMENT_AMOUNT">
<input type="submit" name="PAYMENT_METHOD" />
</form>
I can submit this form, but i want save form data before submit
View:
@mod.route('/payment/', methods=['GET', 'POST'])
def payment():
if request.method != "POST":
return render_template('form.html')
form = request.form
form_data = {'PAYEE_ACCOUNT': form['PAYEE_ACCOUNT'],
'PAYEE_NAME': form['PAYEE_Name'],
'PAYMENT_AMOUNT' : form['PAYMENT_AMOUNT']
}
# Save Data
import urllib
params = urllib.urlencode(form_data)
url = 'http://www.example.com'
return redirect(url, params)
Please help me
I've solved this problem by using JavaScript.
First, sending the data to server.
JavaScript code:
Then, saving the data and returning result.
View code: