I just created the img tag in HTML using document.write
in javascript.
This is a matter to postpone later, and what I want to make is to freely place the img tag with the number id in the box as shown in the picture below:
I thought I could create a css grid and specify a variable for each column (for example, _0101
, _0102
...) and make it (e.g.) #id_number {position: '_0101'; }
.
//index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="test.css" type="text/css">
<title>title</title>
<script src="test.jsp"></script>
</head>
<body>
<script>
document.addEventListener("DOMContentLoaded", upload());
</script>
</body>
</html>
//test.jsp
function upload() {
var iSet = '';
for(var i = 1; i < 301; i++) {
if (i < 10) {
iSet='00' + i;
} else if (i < 100) {
iSet='0' + i;
} else {
iSet=i;
}
document.write("<img class='_"+i+"' src='./img/" + iSet +".webp' style='width:10%' onclick='changeStyle(" + i + "); save();' onerror=\"this.style.display='none'\">");
}
}
First, The created image can often be repositioned. In the picture above, the id="1"
image is in [1, 1]
but I would like to be able to do it as a column because I might need to change it to [1, 2]
.
Of course, if it's not possible, I'll put it in absolute position (then I want to know if I can manage the coordinates of absolute position by putting it in a variable).
Thank you very much for your reply and I hope you have a good day.