After creating a few text input form in a table (see my previous post here) , it’s time to make them functional. The most basic thing that the web app should do is to get the input from user and display them in another table afterwards.
First, let’s identify a few sections that are closely related in order to get the input and display them.
– use jquery will be much easier.
– this is where we will command to get the input from the relevant IDs and somehow display the input.
– the submit button should have its ID too.
– this will be the section which i will display user’s input.
(no python function required at this stage yet)
It introduces document.writeIn() but where does it write to? I did not try this.
All in all, i have been using jQuery and there must be someway i can use it to do anything. Yes, in fact everything should just be a direct application of its API.
So here’s what i did to get an input from user and display it below the config table when the button “submit” is pressed.
- in HTML form:
- in HTML display:
<form name= “input” action=”#” method=”get”>
<input type=”text” name=”firstnumber” value=” ” id=”number_one”>
<input type=”submit” id=”configsubmit” value=”Submit”>
this is the key that i have been looking for! Which delete whatever is in the list before appending it
.append() will not work because it will keep on adding the the inout value at the end of the sentence.
.replaceWith() will not work because it only replace once.
I found this useful information from here: how to do a repeated replace or update in jquery
With these, i passed a simple test for one input and i can proceed with the rest of the inputs and move on to post the data to python function! 😀