Why doesn't this work? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
1st Sep 2019, 6:27 PM
Rishan [da_coder, semi-active]
Rishan  [da_coder, semi-active] - avatar
11 Answers
+ 5
var result; var color; window.addEventListener('load', init); function init(){ color = document.getElementById("color"); result = document.getElementById("hexValueResult"); } function findHexValue() { result.value = color.value; } function copyResult() { result.select(); document.execCommand("Copy"); }
1st Sep 2019, 7:34 PM
Coding Agent
Coding Agent - avatar
+ 7
It did! Thanks!
1st Sep 2019, 7:36 PM
Rishan [da_coder, semi-active]
Rishan  [da_coder, semi-active] - avatar
+ 5
Doesn't work still for some reason...
1st Sep 2019, 7:32 PM
Rishan [da_coder, semi-active]
Rishan  [da_coder, semi-active] - avatar
+ 4
You have to set the value attribute of result.
1st Sep 2019, 7:19 PM
Coding Agent
Coding Agent - avatar
+ 4
window.addEventListener('load', init); function init(){ var color = document.getElementById("color"); var result = document.getElementById("hexValueResult"); } function findHexValue() { result.value = color.value; } function copyResult() { result.select(); document.execCommand("Copy"); }
1st Sep 2019, 7:28 PM
Coding Agent
Coding Agent - avatar
2nd Sep 2019, 5:39 PM
Paolo De Nictolis
Paolo De Nictolis - avatar
+ 3
Yep it works, good job
1st Sep 2019, 7:46 PM
Minerals2016
Minerals2016 - avatar
+ 2
Minerals2016 Thank you!
1st Sep 2019, 7:49 PM
Coding Agent
Coding Agent - avatar
+ 2
Coding Agent you're welcome :)
1st Sep 2019, 7:51 PM
Minerals2016
Minerals2016 - avatar
+ 2
Thanks
2nd Sep 2019, 4:30 PM
abdirahman abdilahi ahmed
abdirahman abdilahi ahmed - avatar
0
Check it very well before you use. Or always look out for bugs in your code
3rd Sep 2019, 5:19 AM
Ismail Abdulroheem
Ismail Abdulroheem - avatar