Minecraft PC IP: play.cubecraft.net

Max ♠

Forum Expert
Feb 20, 2016
1,420
2,940
344
25
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,940
344
25
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

>.> I will be back to the community and then leave again.
BicolourSine41 🇺🇦 wrote on Mintypie231's profile.
'Hello' said by afk human
It's so infuriating when your enemy takes less knockback than you and you take the maximum knockback, even if you both are in the same ping range! I know I'm not the only one this is happening to
Eli
Life never ceases to surprise you!
AronTheLlama wrote on Verbramdt's profile.
Verbramdt
Top Bottom