Minecraft PC IP: play.cubecraft.net

_Oplex_

Dedicated Member
May 5, 2016
694
1,059
198
Under Your Bed (O.o)
With the web app that i have here, the user needs to hand select the color's. And i have a limit of the colors that are usable. i want to have a color-picker that the user can use to select the drawing color. but i dont get it to work.

what i have right now:
https://projectmediavormgeving.github.io/Files/Samir/paint.html (you need to enable scripts to let it work.)

what i want:
12yji.png
 

Max ♠

Forum Expert
Feb 20, 2016
1,420
2,939
344
26
North pole
HTML:
<input type="color" onchange="var color = this.value">

The chosen color is stored in the variable color
 

Max ♠

Forum Expert
Feb 20, 2016
1,420
2,939
344
26
North pole
i have my script and html separated from each other, So now i get "Unused local variable color"
Create a global variable called color at the start of the document,

Change the HTML from before to
Code:
<input type="color" onchange="color = this.value">

Also, having the js and html seperated wasn't the problem, the variable where the value was stored was a local variable so you could only interact with it inside the onchange of the input tag. Method above should work
 

_Oplex_

Dedicated Member
May 5, 2016
694
1,059
198
Under Your Bed (O.o)
Create a global variable called color at the start of the document,

Change the HTML from before to
Code:
<input type="color" onchange="color = this.value">

Also, having the js and html seperated wasn't the problem, the variable where the value was stored was a local variable so you could only interact with it inside the onchange of the input tag. Method above should work
giphy.gif
 
  • Like
Reactions: Max ♠
Members Online

Latest posts

Latest profile posts

NEWS: Summer Event is now in development and it's been confirmed that 5 weeks of Summer is back!
However, the SkyWars Update is moved to the BLOCKED category. In other words, it's delayed (Cam says it's on hiatus, but development resumes soon)
1780775881384.png
AliWarrior wrote on Mivke's profile.
Thanks for the follow!
It's been over 3 years since I reached #1 on the EggWars leaderboard.

Time flies, and I really miss the 2018–2023 Java community.

I never thought I'd miss it this much...
how to apply for owner
aienmg9 wrote on SfenKer's profile.
Hi, can I be your first friend?
Top Bottom