Form Submission and Routing to New Page

I’m trying to create a form with multiple kinds of inputs. I would like to save these inputs into a Pandas Dataframe and eventually write it into a PostgreSQL database on clicking the Submit Button. I would also like to re-route to a new page containing an editable dash table containing values read from another PostgreSQL table.

I’m new to Dash but I’m working on a great project. Would appreciate any help!


1 Like

Work around:

html.A(html.Button(‘Submit!’, id=‘submit’),

1 Like

Also, I would like to know how to implement the Clear Form functionality where all the inputs are refreshed to defaults on button press.

You can do a regular form with dash html components, then add a route to the flask server to handle the form submission.

Basic example:

import flask
import dash
import dash_core_components as dcc
import dash_html_components as html

app = dash.Dash(__name__)

app.layout = html.Form([
    html.Button('Submit', type='submit')
], action='/post', method='post')

@app.server.route('/post', methods=['POST'])
def on_post():
    data = flask.request.form
    return flask.redirect('/')

if __name__ == '__main__':
    app.run_server(debug=True, port=7779)
1 Like

You can clear form with a html.Button('clear', type='clear').

1 Like

HI Philippe.
I am trying to run strikethrough application inside flask application.
I want to save the selected parameters.
my web link:
after i select the time, it is:
I just tried your example and changed it to GET but it didn’t work as expected.
Please help me …