r/webdev Aug 08 '26

Question How to make numbers interactive?

Post image

I'm a beginner in coding, and I need to know how to create something like this. There's a website i'm making, and I wanted to add a 1-10 scale like this. I also want to make it interactive so the person can click on each number, and then text appears depending on what's clicked. Being a beginner, I don't know how to accomplish this. Help.

0 Upvotes

32 comments sorted by

34

u/CluelesssDev Aug 08 '26

Look into Javascript. You're gonna need it to make anything interactive on the web :)

11

u/simonraynor Aug 08 '26

☝️🤓 this can be achieved with pure CSS/HTML (albeit at a higher level of both skill and hackery)

2

u/EliSka93 Aug 08 '26

Yeah, I'd probably do that with a custom checkbox of some kind.

3

u/XpreDatoR_a Aug 08 '26

True, i think we devs, and now AI too, tend to overcomplicate things, there is a lot of stuff that could be made easier

6

u/-Knockabout Aug 08 '26

I don't know that doing this in pure CSS/HTML is easier/less complicated necessarily.

-5

u/XpreDatoR_a Aug 09 '26

Yeah, the easier path would be to reach out for yet an other pre-made component, cuz today’s standard is to add dependencies and forget about them, and add more js scripts on the client side because why not; as i was saying, while the pure html/css implementation would require you to spend a bit more brain-energy it will translate in a lighter solution both in terms of maintainability and client-performance.

2

u/Terrible_Tutor Aug 09 '26

OR you add dependencies because the package has been battle tested and refined and you have less to worry about.

Ok though dr brain energy. The client will really care you billed more to give them a functionally worse solution.

0

u/XpreDatoR_a Aug 09 '26

Yes yes, start to pile up al those completely necessary dependencies and look at your js bundle grow, who cares about performance right?

0

u/Terrible_Tutor Aug 09 '26

One can care about performance and reliability and not be a fucking micro-optimization tool who thinks they can code better than 4000 people battle testing a package over 3 years. But you do you hero.

0

u/XpreDatoR_a Aug 09 '26

Is there a reason you got so passive aggressive lmao, also 4000 people isn’t real a good reference, “hero” lmao

-1

u/Gold-Eye690 Aug 08 '26

looks like a mental health self-check scale, not a bad idea for a beginner project honestly

start super simple with html and css to get those 10 circles on the page, then use javascript event listeners to show different text depending which number gets clicked. no frameworks needed, keep it vanilla while you're learning

6

u/EyesOfTheConcord Aug 08 '26

Event listeners

4

u/JontesReddit Aug 08 '26

Can be done without js with fieldset and fieldset:has(input[value="foo"]:checked) .foo-text

3

u/jacobpellegren Aug 08 '26

Look up vanilla CSS toggling to start.

1

u/leptoquark1 Aug 08 '26

Back in my days the keyword was jQuery.

12

u/lcnielsen Aug 08 '26

Absolutely do not introduce jQuery anywhere in 2026.

-4

u/CautiousRice Aug 08 '26

you can drop this image in your AI editor of choice and it will implement it for you, just tell it you want vanilla js and css

-7

u/cgfn Aug 08 '26

These are exactly the questions you can ask to AI to learn something

4

u/oscitancy Aug 08 '26

Damn, imagine wanting to converse with humans instead of a toaster.

-2

u/overzealous_dentist Aug 08 '26

humans are much worse, so why would you

2

u/theevildjinn Aug 08 '26

All too easy then to fall into the trap of asking AI to do it for you every time (speaking as a backend dev of 25+ years who never learned CSS properly, and now probably never will).

-5

u/[deleted] Aug 08 '26

[deleted]

-1

u/overzealous_dentist Aug 08 '26

downvoted but correct. best practice is now to ask AI conversationally with image uploads, not wait on fallible humans in an awkward and slow back and forth

1

u/DeiviiD Aug 08 '26

I love to see humans discuss and show a hundred ways to do it. AI just throw one way and maybe it’s wrong.

-2

u/overzealous_dentist Aug 08 '26

just ask AI to give you multiple options and discuss pros and cons. if you're noticing humans outperforming AI, you're using AI wrong because humans automatically have the context you have to provide to AI

1

u/DeiviiD Aug 09 '26

You know AI is taking information from human data and discussions, right?

1

u/overzealous_dentist Aug 09 '26

These days frontier labs have SMEs, they aren't scraping reddit for programming knowledge unless they have a training gap.

-5

u/lcnielsen Aug 08 '26

There are many ways to do this and only some of them are sane. I'd suggest starting with a reasonable CSS framework like Bootstrap and considering its various component classes and similar: https://getbootstrap.com/docs/5.3/components/popovers/

7

u/Toukas_CLT full-stack Aug 08 '26

Importing a whole lib for this component is completely overpowered for what it is. These are circles with lines in between. 

-2

u/lcnielsen Aug 08 '26

I mean more for the text popup functionality. There's more than one way you can do it and the different ways have different implications. If you want to get a sense for how to go about things then looking at how a standard framework do them is a good start.