This was a subject closed up by no means answered on this:
That is the code:
This works positive in that it’ll show a textual content enter field to kind in.
The query I’ve is how does the inputted textual content turn out to be a worth you could enter into the database?
The choose fields and some other info that’s to be added to the database must be wrapped in a form field, in order that the shape’s info will be despatched to some backend code that updates the database.
I understand how to wrap in a kind discipline. Try this on a regular basis and I exploit dropdowns steadily. The worth of that is suppose to be what’s typed within the enter field. However as written, it simply provides the phrase “Different” to the database as a result of that’s the worth.
So, based mostly on that JS, I wasn’t certain how one can take the textual content typed and use that as the worth that goes to the database.
<choice worth="Different">Different Sources, Please Specify</choice>
Give the choice within the HTML code a reputation attribute, and that can be submitted to the database.
Must you add and take away the identify attribute from the choice relying on if that choice is legitimate or not? No you shouldn’t. The choice ought to all the time be submitted to the backend kind, and that sort of resolution must be made by the backend itself.
Why ought to the backend be chargeable for that sort of resolution? As a result of you shouldn’t belief something from the frontend. It’s too simply exploited by every kind of issues. The backend is the place the place dependable choices are made.
Leave a Reply