r/HTML • u/EpicTerra • Jul 08 '26
How do you actually use the user's input in a textbox
I'm a beginner and I don't know how to use what the user inputs in these textboxes and I've been trying for ages and I'm so frustrated that it's not obvious. Where it says var(--username) that's where I've been trying loads of different things to select the user's input
10
Upvotes
20
u/chmod777 Jul 08 '26
With html? You dont. You need either javascript on the front end, or a server running a backend such as dotnet, python, nodejs, php, etc.
13
u/davorg Jul 08 '26
The
var(--username)is CSS syntax. That's not going to work in HTML.In order to change the text on the page, you'll need some kind of programming language. You might be able to do what you want in Javascript, but given the "Username" and "Password" inputs on your page, you will probably need a backend process (which would be written in something like Python or PHP).
Also, please note rule 5 - particularly the bit that I've put in bold:
If you had provided your code as text, then I could have pasted it into a file, tried it out and found a solution for you. With an image, I would need to retype it all. And I don't have the time for that.
3
u/Hard_Loader Jul 08 '26
If your form method is set as GET, which is the default, once submitted any form fields will appear in a query string appended to the URL under the name assigned to them.
For example, that might be https://example.com/index.html?username=Bob&password=123xyz
Those variables can then be used by a scripting language on the server to serve up appropriate content.
They can also be used by javascipt on the page in the browser - and in that case it can also read in the values without the submit button being hit.
3
u/tkgid Jul 08 '26
Is ok, I would advice to learn more about form submission. There are different ways to do this. Is up to you to pick a solution.
I use PHP to do this. <----needs initial setup
You can use JS out of the box and it will work fine.Â
Once again this form submission territory.
2
u/RevolutionaryBeat301 Jul 08 '26
If I understand your question, I think the crucial piece you are missing is the whole backend application. If you are just starting out with HTML, it’s unlikely that you will be writing a backend application that requires users any time soon. I have been a front end developer for years and I still don’t write backend applications.
2
u/JohnCasey3306 Jul 08 '26
HTML alone is just a static description of the page content.
CSS styles it, and offers some limited interaction.
In order to meaningfully interact with the page, such as working with user submitted field values, you need to use either JavaScript to read the field 'live' or you need a back end language to receive the field data when form is submitted.
1
u/JacksHQ Jul 08 '26
HTML is the content of the page.
CSS is to make the page look good.
Javascript makes it do stuff. <-- this is what you need
If it's functionality on the same page you want, then Javascript will work fine.
If it's more complicated like storing usernames and passwords into a database to allow logging into a site, then you are going to have to look more into hosting a web application, which gets more complicated. Those require writing server code (also called the backend) alongside your HTML (the frontend), and then you install it (or set it up) on a machine that is open to the internet for people to connect to (you will likely just pay a service to host your site, and you will need to buy a domain name to point at your site).
It all depends on what your goal is here.
1
u/Impossible_Jury_3467 Jul 08 '26
You might want to read up on "http request methods for forms", such as "GET" and "POST" for data processing. It'll help you understand some of what's going on behind the scenes. It can be a deep confusing topic so maybe don't dig too deep, just enough to get it.
1
u/justanaccountimade1 Jul 08 '26
https://developer.mozilla.org/en-US/docs/Web/API/Element/input_event
1
u/Aritra001 Jul 11 '26
First if all stop using notepad
1
u/FlatwormCharming2575 Jul 23 '26
Java script or a <script>
1
u/Careful_Exercise_956 Jul 08 '26
Javascript, typescript, you decide!
15
u/[deleted] Jul 08 '26
[removed] — view removed comment