+ 2

HTML input + JS. This code is though (for me), can u help

HTML line: 13; JS line 55; There are over a 100 inputs and table td / th. I accessed them with TagName (in the js). First run the code, then the first input, in front of round and under the "players names" -- You type something in it (names[2].innerHTML = nameInp[0].value). And click "done", So then the input disappears and the first name is input.value. Issue: when I click on done again, the names[2] disappears. Why & how do u fix that? (kinda hard to explain); https://code.sololearn.com/WShYa2MbsX7l/?ref=app

23rd Jul 2019, 1:59 AM
Ginfio
Ginfio - avatar
13 ответов
+ 1
https://code.sololearn.com/Wy0OneUPhLUm/#html
23rd Jul 2019, 4:44 AM
ODLNT
ODLNT - avatar
+ 1
ODLNT Thanks. Alll fixed ✔️. 💡
23rd Jul 2019, 4:47 AM
Ginfio
Ginfio - avatar
0
Ginfio You need to increment the names collection when the "done" button is clicked, instead of leaving it at 2, that way the next table header will be assigned the next input value.
23rd Jul 2019, 3:43 AM
ODLNT
ODLNT - avatar
0
Cbr✔[ Not Active ] have u tried running the code (u edited)? it doesn't seem to be working.
23rd Jul 2019, 3:43 AM
Ginfio
Ginfio - avatar
0
ODLNT , that's what i was thinking, But i figured i didn't know how. Can u show me how to do it / edit my code, or create new example _ please
23rd Jul 2019, 3:48 AM
Ginfio
Ginfio - avatar
0
let i = 2; function update_name(){ names[i].innerHTML = nameInp[0].value; i++ }
23rd Jul 2019, 3:49 AM
ODLNT
ODLNT - avatar
0
Cbr✔[ Not Active ] did u remove the code (u edted), for some reason i'm not seeng it on here.
23rd Jul 2019, 3:51 AM
Ginfio
Ginfio - avatar
0
ODLNT , it doesn't seem to work for me > let i = 2; function . . . }
23rd Jul 2019, 3:55 AM
Ginfio
Ginfio - avatar
0
Ginfo let i = 2; should be outside of the update_name function
23rd Jul 2019, 3:58 AM
ODLNT
ODLNT - avatar
0
ODLNT Awosome💡, now can we limit it to only the top 10 inputs,
23rd Jul 2019, 4:02 AM
Ginfio
Ginfio - avatar
0
Ginfio Now that you are using the variable i to increase the names index you can also use it to check if the done button has been pressed 10 times using an if statement.
23rd Jul 2019, 4:07 AM
ODLNT
ODLNT - avatar
0
ODLNT , Ok, and how do u do that? // !(it sounds like i'm makin u do everything or asking too much, but really these are the things i don't know how to do)!
23rd Jul 2019, 4:13 AM
Ginfio
Ginfio - avatar
0
ODLNT Something like this? (it ignored what i wrote though, https://code.sololearn.com/WShYa2MbsX7l/?ref=app it looks right, but doesnt work
23rd Jul 2019, 4:40 AM
Ginfio
Ginfio - avatar