+ 3

Input with button

I have a two <input Type="text"> <input type ="text "> when I will write text and click my <button >ok</button > I want to text add my div when have a display none and will show div when I will click OK button

30th Apr 2017, 11:40 AM
Kristina Hakobyan
Kristina Hakobyan - avatar
36 Answers
+ 9
1 year maybe started using it more once i joined sololearn
30th Apr 2017, 3:32 PM
Burey
Burey - avatar
+ 8
ty js is a really fun language and seems it is only on the rise and good luck to you on your future endeavours
30th Apr 2017, 3:46 PM
Burey
Burey - avatar
30th Apr 2017, 12:27 PM
Burey
Burey - avatar
+ 7
i made changes already to the code you supplied in jfiddle and it works with numbering for me. i am having hard time understanding what is the issue you are having with the ul/ol
30th Apr 2017, 2:50 PM
Burey
Burey - avatar
+ 6
ol is ordered list with order being the numbers ul is unordered list so each item is marked with • just go with ol xD
30th Apr 2017, 2:40 PM
Burey
Burey - avatar
+ 6
ohh..... mind uploading the code here on the playground?
30th Apr 2017, 2:42 PM
Burey
Burey - avatar
+ 5
re-check my code @Calvin no problem the more the merrier xD
30th Apr 2017, 2:08 PM
Burey
Burey - avatar
+ 5
xD
30th Apr 2017, 2:20 PM
Burey
Burey - avatar
+ 5
added a button inside each li the onclick handler is the function removeEl which assign the parentElement to the element which was sent as a parameter and then thru its parent remove the entire li element
30th Apr 2017, 3:27 PM
Burey
Burey - avatar
+ 4
i suggest you make a code in the playground and link to it it would help us to help you better also we could work on existing code and see the problem more easily
30th Apr 2017, 12:05 PM
Burey
Burey - avatar
+ 4
change to ol for numbering there is already a <ol> inside the div i just add list items <li>input1 input2</li> into it but with ol you will get for inputs 1 test 2 test the following: 1.1 test 2.2 test so the input for number is not needed as ol adds this for each item added
30th Apr 2017, 2:17 PM
Burey
Burey - avatar
+ 3
1 text 2 text ....... represent each input? like if first input is 1, text and the second is 2, text and so on so each time you click the button it is added to the list?
30th Apr 2017, 1:58 PM
Burey
Burey - avatar
+ 3
thx so much u today help me understand my homework 🤘👏
30th Apr 2017, 3:53 PM
Kristina Hakobyan
Kristina Hakobyan - avatar
+ 2
function g(){ var c=document.getElementById('demo1'); c.style.display="block"; var inp=document.getElementsByTagName('input'); document.getElementById('demo1').innerHTML = document.getElementById('inp').value; }
30th Apr 2017, 11:42 AM
Kristina Hakobyan
Kristina Hakobyan - avatar
+ 2
ok I will do it
30th Apr 2017, 12:08 PM
Kristina Hakobyan
Kristina Hakobyan - avatar
+ 2
updated code added inp[i].value=""; this will clear the fields and i used for loop because, what if you added more onput fields in the future? no need to modify anything else or if you remove an input field
30th Apr 2017, 1:54 PM
Burey
Burey - avatar
+ 2
ok sorry don't see html thx so much 👍👍🤗
30th Apr 2017, 2:18 PM
Kristina Hakobyan
Kristina Hakobyan - avatar
+ 2
u know now I'm thinking how I can after delete my each list line I'm thinking do it remove.childe I'm right
30th Apr 2017, 3:06 PM
Kristina Hakobyan
Kristina Hakobyan - avatar
+ 2
good but I don't understand u can explain me
30th Apr 2017, 3:22 PM
Kristina Hakobyan
Kristina Hakobyan - avatar