₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,325,903 members, 8,424,133 topics. Date: Wednesday, 10 June 2026 at 06:10 PM

Toggle theme

Help With A Javascript Problem - Programming - Nairaland

Nairaland ForumScience/TechnologyProgrammingHelp With A Javascript Problem (548 Views)

1 Reply (Go Down)

Help With A Javascript Problem by morzook(op): 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:
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].
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
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.
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.
Re: Help With A Javascript Problem by chukwuebuka65(m): 11:15am On Sep 03, 2022
jbreezy:
It’s because you didn’t increment the index of your box.
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:
grin grin grin

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
grin
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? undecided
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.
Re: Help With A Javascript Problem by niel63(m): 8:24pm On Sep 03, 2022
LikeAking:
Op, getat!
grin wetin he do you now?
1 Reply

Everybody Is A Javascript Developer On Nigerian Tech TwitterJavascript ProblemHelp Me With This Javascript Problem234

Seo Made Easy ..a Beginners Guide To Search Engine OptimizationI Need A Vtu WebsiteCost Of Building A Mobile And Web App