Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,194,386 members, 7,954,562 topics. Date: Friday, 20 September 2024 at 10:17 PM |
Nairaland Forum / Science/Technology / Programming / Help With A Javascript Problem (450 Views)
HELP With This Javascript Problem / Javascript Problem / Help Me With This Javascript Problem (2) (3) (4)
Help With A Javascript Problem by morzook(m): 9:55pm On Sep 02, 2022 |
I am building a clone of the popular game, 4 pics 1 word and I have an issue I am battling with. As shown in the image, I want to populate the empty boxes with each alphabet clicked from the alphabet options below it. The issue now is that for each time I click the alphabets, only the first box gets updated. The other three never gets updated. How do I go about it? I can apccess each box by using childNode[index].
|
Re: Help With A Javascript Problem by Fourpockets: 11:11pm On Sep 02, 2022 |
morzook: You could store the values of the letters you clicked in an array, and then map it onto the boxes, everytime you click the letters, run a function to map it, this is the easiest solution I could give off head 1 Like |
Re: Help With A Javascript Problem by chukwuebuka65(m): 10:09am On Sep 03, 2022 |
First , the values for the boxes should be stored and read from an array. Secondly, I believe your alphabets are also stored and read from array of objects (with id and value properties) that you map through adding a click event that runs the function above ,the id from the object and then creating an <li> tag that contains the alphatbet. Lastly you need a function should get the e.target.value or map through ur array of alphabets to get the alphabet clicked and then also map through you array of boxes to add the alphabet clicked. If you didnt understand the above explanation. Maybe you should take a screenshot so we see exactly where the bug is. 1 Like |
Re: Help With A Javascript Problem by jbreezy: 10:36am On Sep 03, 2022 |
It’s because you didn’t increment the index of your box. 1 Like |
Re: Help With A Javascript Problem by chukwuebuka65(m): 11:15am On Sep 03, 2022 |
jbreezy: If he increments the index of the box. I think its going to get that particular index and still leave out the rest |
Re: Help With A Javascript Problem by Sleekcode: 11:53am On Sep 03, 2022 |
1. Store ur boxes in array On button of ur text click loop and check the box arrray n if the first array box value length is greater than 1 since each box can only hold one value. if the first box in the array is greater than one.... Now move to the next box in the array and let it have the value of the clicked event... if all your boxes are filled simply add return to stop ur function from doing anything else. If u remove or edit out a value from any box set the box value on change to 0;. ur app should work well now 2 Likes |
Re: Help With A Javascript Problem by dragnet: 12:10pm On Sep 03, 2022 |
display your code |
Re: Help With A Javascript Problem by Karleb(m): 12:15pm On Sep 03, 2022 |
How are you people debugging without seeing the code? Are you guys witches? 1 Like |
Re: Help With A Javascript Problem by LikeAking: 5:17pm On Sep 03, 2022 |
Op, getat! |
Re: Help With A Javascript Problem by niel63(m): 8:23pm On Sep 03, 2022 |
Even stackoverflow or any other dev forum would always recommend you show some piece of code. An example of what you've attempted that's not working for you. 1 Like |
Re: Help With A Javascript Problem by niel63(m): 8:24pm On Sep 03, 2022 |
LikeAking:wetin he do you now? |
(1) (Reply)
Impact Of Web Design On The Content Marketing Strategies! / Mcreator Download [ 2023 ] Best Minecraft Mod Maker Software / I Made A Game
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 15 |