Do I require a Javascript framework, or can I achieve the desired functionality with the

During my time building Microsoft Excel apps using VBA, I worked with events like _Change and _Click.

Transitioning to JavaScript and frameworks was a bit overwhelming due to the asynchronous nature of it all.

Moving on to Python and Flask has been a refreshing change for me.

However, when it comes to frontend development, I struggle with creating dynamic forms as I can't find the equivalent tags (such as document.getElementsBy in JavaScript) and events (like onChange, onClick) that I used in VBA.

Just yesterday, I faced a challenge where I needed to update SelectField options based on user input in a TextField. This required me to incorporate <script> tag and write JavaScript snippets:

    <script>

    //Accessing elements:
    let train_number = document.getElementsByClassName('train-number');
    let stops_list = document.getElementsByClassName('stops-list');

    //Adding event listener:
    train_number[0].onkeyup = (e) => {
        //Clear stops_list:
        if (train_number[0].value == '') {
            stops_list[0].options.length = 0;
        }
        //Alphanumeric characters check:
        let charStr = String.fromCharCode(e.which || e.keyCode);
        if (/[a-z0-9]/i.test(charStr)) {
            //Clear stops_list:
            stops_list[0].options.length = 0;
            searched_train = train_number[0].value;
            //Fetching stations data:
            fetch('/train/' + searched_train).then((response) => {
                response.json().then((data) => {
                    for (var i = 0; i < data.length; i++) {
                        //Creating new option element
                        var opt = document.createElement('option');
                        //Adding text node to option element (opt)
                        opt.appendChild( document.createTextNode(data[i]) );
                        //Setting value property of opt
                        opt.value = data[i]; 
                        //Adding opt to select box (sel)
                        stops_list[0].add(opt); 
                    }
                })
            })
        }
    }
</script>

Now, here's my question: Can dynamic forms and views be created using only Flask? Or would it be more beneficial to switch to another framework? If a framework change is recommended, which one do you suggest that is simple, lightweight, user-friendly, easy to learn, and preferably synchronous?

Answer №1

Using JavaScript is pretty essential for most web development projects. While WebAssembly is also an option, it may not integrate well with Python at the moment.

While Stack Overflow doesn't provide explicit advice, one framework worth considering is Vue if you prefer something less complex.

If you're interested in learning about event-based JavaScript functions in the browser, take a look at the Events Overview page on MDN's website.


From my understanding, Node.js serves as a back-end technology while Express is a useful framework for routing and other tasks. For single-page applications that require front-end routing, options like Vue, React, or Angular could be beneficial.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Tips for specifying the "url" parameter in xmlhttp.open() for utilizing Ajax in communication with node.js

server.js has the ability to generate a random number. I am trying to retrieve a random number from the server and utilize xmlhttp to send a request. However, the string value remains unchanged when I visit http://localhost:3000/index.html. What could be c ...

What is the best way to connect or link to a HTML table row <tr>

Is there a way to trigger an alert when the user double clicks on the whole row? ...

Struggling to extract text from within a <p> tag on an Ionic 1 app page on iOS

After developing an ionic-1 application for iOS and Android devices, I encountered an issue with displaying mobile numbers in one of the views. The numbers are contained within <p> tags. While users can click and hold on a number to copy it on Andr ...

When using React, draggable components with input fields may lose their ability to receive focus when clicking on the input field

<Draggable axis="y" grid={[135,135]} onStop={this.handleStop} defaultPosition={{x: this.props.task.positionX, y: this.props.task.positionY,}}> <div id="edit-task-component"> <form onSubmit={this.handleSubmit} id=" ...

What is the best method for extracting information from this data? (extracting data from

I need assistance. I've written multiple arrays to a text file and now I'm trying to parse them. What am I doing incorrectly? fs.readFile("./data.txt", "utf8", function(error,dataRes){ console.log('Reading data') ...

Transforming data from a JSON format into a JavaScript array

I'm trying to convert a JSON string into an array containing the values from the JSON. When I use json.stringify(jsonmybe) and alert it, I see [{"role":"noi_user"},{"role":"bert_user"}] (which is in JSON format). My goal is to extract `noi_user` and ` ...

Update Table Row Background Color in Separate Table by Clicking Button Using JQuery

Two tables are involved in this scenario - one that receives dynamically added rows, and another that stores the data to be included. The illustration above displays these tables. Upon clicking the Edit button, the information from the selected row in Tab ...

What is the best way to extract all image URLs from a website using JavaScript?

There are various methods to retrieve image src urls using JavaScript, such as utilizing document.images or by targeting all img elements and fetching their src attributes. However, I am currently unable to extract the image urls specified within CSS styl ...

I'm unable to resolve the issue regarding the message "Property or method is not defined on the instance but referenced during render."

I have a good grasp on what the issue is (the inputs I'm trying to v-model aren't declared), but for some reason, I can't resolve it (or figure out how to) even after studying other posts with the same problem. After comparing my code with ...

Why is my JSON object being mistakenly interpreted as a string literal during iteration?

I'm facing a seemingly simple question but I can't seem to figure it out. Below is the jQuery code I am working with: $(function() { $.get(urlGetContainerNumbers, function(data) { console.log(data); for (var idx = 0; idx &l ...

Retrieving information from nested JSON objects using JavaScript

I'm struggling with extracting data from a JSON array object. Despite trying to use Iterables & Iterators, I can't seem to grasp the concept. { '-LIDMHr69GLnq1Pyzt6o': { author_avatar: { image: 'https://lh3. ...

The functionality of Bootstrap toggle ceases to operate properly following an AJAX content update

I am currently using AJAX load to fetch some content on my webpage. I am working with Bootstrap 3 and Bootstrap toggle. When the content is loaded, the Bootstrap 3 content functions properly (the panel-primary panel is clearly visible). However, the Bootst ...

Tips for customizing the background color of the MUI Menu Popover within a TextField that has the select property

In my quest to customize the appearance of a popover or menu in a TextField with the 'select' property, I referred to MUI customization docs for guidance. Successfully changing the text and label color of a TextField using the code below: const u ...

Mist Conceals Celestial View (THREE.JS R76)

I have a cylindrical camera setup with fog to hide the end of the tube. However, I am trying to make the skybox visible through the alpha map sides of the cylinder. The current issue is that the fog is blocking the visibility and I'm looking for a sol ...

What is the significance of having multiple route parameters in Express?

The RESTful API provided by cex.io offers a route that can return pairs of all currencies with a variable amount of parameters. In express, how can we achieve similar functionality? Consider the following pseudo code example... app.get('/pairs/:arg ...

When using a PhoneGap app to access a webservice, are there any potential cross-site issues that could arise?

How can I access an external web service from a PhoneGap app using AJAX without needing to rely on CORS or JSONP to bypass the cross-origin issue? I've come across a question on Stack Overflow suggesting that cross-site HTTP calls are not a problem wi ...

Encountering the error message "Attempting to access properties of undefined (specifically 'map')". Despite having the array properly declared and imported

I am facing an issue while trying to iterate through an array and display names for each person. Despite declaring the array properly, it is returning as undefined which is causing the .map function to fail. Can you help me figure out where I am making a m ...

Cryptocurrency price tracker with sleek Bitcoin symbol and FontAwesome icons

My assignment involved creating a function that retrieves Bitcoin trades from a JSON URL, allows users to change the interval with buttons, uses fontawesome arrows to indicate rate changes (up/down/no change), and displays the data on a website. Everythin ...

Is it possible to dynamically assign a template reference variable to a newly created DOM element in TypeScript?

After creating a DOM element with this.document.createElement('h1'), I am looking to insert the element into a section tag using a template reference variable (myTRF), similar to the example below: <section> <h1 #myTRF>This is my he ...

The process of styling with styled components in Mui - a guide to styling

Currently, I am facing challenges with styling and organization while working on a new react project with material ui and styled components. Despite researching best practices for styled components, I am still struggling to find an effective solution for s ...