0
Function Problem
Hey guys... Why myFunction doesn't work here and doesn't print the comments? Please help! I want this code to print the comments and also create button number 2 after adding five comments. Help me if you know how to do it https://code.sololearn.com/WAM8w5gWtOsa/?ref=app
14 odpowiedzi
0
In button tag you mised ()
myfunction()
0
Line 41 and 64
document
dudument
line 43
getElementsByTagName
missed s and document
0
Divya Mohan i corrected them😁 but it still dosen't print the comments... it just prints [object inputHTMLElement]
0
Line 63
Correct it as
document.getElementsByTagName
0
Line 43
document.getElementById("cmnt").value
You missed value there
0
Divya Mohan ok😁🤦♀️ after adding 5 comments it gives me error instead of making a button
0
Is it working well as expected ??
0
Divya Mohan yes i corrected and it works. but the button will not be created after adding more than 5 comments
0
Still you have an error in line 63
You have missed document while accessing body element
0
It will be better if your change type from submit to button in line 33.
I get everything working fine then.
0
Divya Mohan thanks. but just how to say just stop after adding button 2. and if pressed submit again dont make a new button 2 again?
0
In line 59
You have write else
Replace it with
else if(x == 6 )
______&_____________
In this way you can also make an algorithm
that
if x%6 ==0 (means if x is divisible by 6 ) then create a button
else type cmnt
0
Divya Mohan thank you, i have another question, how can i put the button 2 beside the button 1 in this code? one of them is in html and one of them is in script, and they don't come exactly after each other.
0
You can use insertAdjacentElement property of js
Ex-
Target button 1 as btn1
And button 2 as btn2
Then
btn1.insertAdjacentElement("afterend","btn2");
It will place btn2 just after btn1
hope it will work
share code with error if not.