robotcourier
robotcourier

Reputation: 27

reactive dropdown

I'm new to flask and webdev. I cant seem to find any true helpful resources on how to create a reactive dropdown list.

I have 2 variables in another file from a textfile I've formatted. I want to use them in the webapp. They are [1] first authors and [2] total authors

[1] first authors is a list of authors and it should be the values the dropdown menu will have.

[author1,author2,author3]

[2] total authors is a dictionary where each key is a different first author and the values are the coauthors

author1: [helping authors]
author2: [helping authors]
author3: [helping authors]

I want a dropdown menu that when you choose an author, it will show all coauthors

I've copied some code from here but all I've gotten to show is the dropdown menu that dosen't react

Upvotes: 0

Views: 167

Answers (1)

Astros
Astros

Reputation: 179

This is entirely a JavaScript thing; I am not really familiar with flask but had to do the same thing few month ago with Django and I couldn't really find a better solution than to implement it using Ajax.

If you aren't familiar with Ajax Here is a great place to get you started.

This response may also help you.

You can also simply use only JavaScript by loading all your data to a template and dealing with your conditions using JavaScript (maybe an event listener 'change' to a form).

Upvotes: 1

Related Questions