new in js and couldnt find an answer for that. I think its pretty basic BUT
my js code in deleting any html I write before. what i would like to be happen - when pressing "load" button the script will run and create buttons without deleting the "load" button itself and h1 tag.
appreciate your help!
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<h1>check</h1>
<button onclick="printbtns()">load</button>
<script>
function printbtns()
{
gobtns('A',18);
gobtns('B',19);
gobtns('C',20);
gobtns('D',21);
gobtns('E',22);
gobtns('G',9);
}
function gobtns(letter,numberofstorages)
{
//window.alert("sometext");
document.write(letter);
document.write("<br>");
var i;
for (i=1; i<=numberofstorages; i++){
var str1=letter.concat(i);
var btn = document.createElement("BUTTON");
var t = document.createTextNode(str1);
btn.setAttribute("style","color:red;font-size:23px");
btn.appendChild(t);
btn.setAttribute("id", str1);
document.body.appendChild(btn);
}
document.write("<br><br>");
}
</script>
</body>
</html>