- Joined
- Nov 24, 2022
- Messages
- 86
- Reaction score
- 7
Hello I have a problem with such thing. The HTML code is "
<button>Pobranie</button><button>Zapisz</button><button>Kasowanie</button>
<DIV>dddd</DIV>"
Script is :
let u;
function pobierz(){let i=prompt("Jaka nazwa?");return i;};
function wyswietl(nowa){document.querySelectorAll("DIV")[0].innerHTML=nowa;};
function wyczysc(){document.querySelectorAll("DIV")[0].innerHTML="";};
document.querySelectorAll("BUTTON")[0].setAttribute("onClick","u=pobierz()");
document.querySelectorAll("BUTTON")[1].setAttribute("onClick","wyswietl(u);");
document.querySelectorAll("BUTTON")[2].setAttribute("onClick","wyczysc()");
The first function works fine,it takes a value from a prompt window.
The third one also -it clears DIV.
Problem is with the second - it doe's nothing, when I put an alert() into setAttribute - setAttribute("onClick","alert();wyswietl(u);"); it shows alert but doesn't change the DIV element.
I use eval function on iframe content.
Any suggestions?
<button>Pobranie</button><button>Zapisz</button><button>Kasowanie</button>
<DIV>dddd</DIV>"
Script is :
let u;
function pobierz(){let i=prompt("Jaka nazwa?");return i;};
function wyswietl(nowa){document.querySelectorAll("DIV")[0].innerHTML=nowa;};
function wyczysc(){document.querySelectorAll("DIV")[0].innerHTML="";};
document.querySelectorAll("BUTTON")[0].setAttribute("onClick","u=pobierz()");
document.querySelectorAll("BUTTON")[1].setAttribute("onClick","wyswietl(u);");
document.querySelectorAll("BUTTON")[2].setAttribute("onClick","wyczysc()");
The first function works fine,it takes a value from a prompt window.
The third one also -it clears DIV.
Problem is with the second - it doe's nothing, when I put an alert() into setAttribute - setAttribute("onClick","alert();wyswietl(u);"); it shows alert but doesn't change the DIV element.
I use eval function on iframe content.
Any suggestions?
Last edited: