I have a question to you about JavaScript. I want to display form after clicking a button and then when I write something and click submit it must display the value of form on screen. And the problem is that when I click submit it display only for a second. Here is my JavaScript code:
window.onload = function () {
var dod = document.getElementById("dodaj")
dod.onclick = function () {
document.write("<form action='?' id='formualrz'><input id='f1' type='text' name='pole' value='Nazwa'><input id='f2' type='text' name='pole' value='Opis'><input type='submit' id='sub'></form>");
var f1 = document.getElementById("f1");
var f2 = document.getElementById("f2");
var submit = document.getElementById("sub");
submit.onclick = function () {
document.write(f1.value + "<br/>" + f2.value);
}
}
}