What is my plan: Every field should contain an input and a select dropdown. I thought it would be smart to insert this element with JavaScript/jQuery (so they can be edited in one place).
Found this solution and it works but not the way I wanted. It passes my HTML block as a string and didn't interpret it as an HTML statement.
Any possible solutions? I found something with $("#myDiv").html(result); - could this help me?
function selectBuilder(){
var node = document.getElementById('select');
var newNode = document.createElement('div');
newNode.appendChild(document.createTextNode('<div class=\"select\"><select><option>--Select--</option><option>Hello 1</option><option>Hello 2</option><option>Hello 3</option><option>Hello 4</option></select><div class=\"select_arrow\"></div></div>'));
node.appendChild(newNode);
}
body {
margin: 0 auto;
width: 100%;
font-family: LatoLatin,Arial,sans-serif;
}
h1{
text-align: center;
}
.tableContainer{
width: 95%;
display: inline-flex;
justify-content: center;
}
.menuNumber{
width: 50px;
}
.menuTable {
border-collapse:collapse;
border-spacing:0;
width: 100%;
border: 1px solid grey;
}
.menuTable td{
width: 100px;
text-align: center;
font-size:14px;
border: 1px solid grey;
border-width:1px;
overflow:hidden;
word-break:normal;
}
.menuTable th{
width: auto;
border: 1px solid grey;
border-width:1px;
overflow:hidden;
word-break:normal;
}
.menuContent{
height: 150px;
}
.salatContent{
height: 100px;
}
.menuDesc{
display: table;
height: 110px;
text-align: center;
width: 100%;
}
.select {
display: grid;
width: 100%;
height: 40px;
}
.menuDescItem{
display: table-cell;
vertical-align: middle;
width: inherit;
height: 110px;
}
<html>
<head>
<link rel="stylesheet" href="css.css">
<script src="https://code.jquery.com/jquery-3.5.0.js"></script>
<script type="text/javascript" src="js.js"></script>
</head>
<body onload="selectBuilder()">
<h1>Speiseplan</h1>
<div class="tableContainer" >
<table class="menuTable">
<tr>
<th class="menuNumber"></th>
<th class="">Montag</th>
<th class="">Dienstag</th>
<th class="">Mittwoch</th>
<th class="">Donnerstag</th>
<th class="">Freitag</th>
</tr>
<tr class = "menuContent">
<td class="">1</td>
<td class="tg-031e">
<div class = "menuDesc">
<input type="textarea" class="menuDescItem" name="menuOneDescMonday" autofocus placeholder="Menu 1 Montag" >
</div>
<div id="select"><!-- html block should be placed here e.g. --></div>
</td>
<td><div class=""></div></td>
<td class=""></td>
<td class=""></td>
<td class=""></td>
</tr>
<tr class="menuContent" >
<td class="">2</td>
<td class=""></td>
<td class=""></td>
<td class=""></td>
<td class=""></td>
<td class=""></td>
</tr>
<tr class="menuContent">
<td class="">3</td>
<td class=""></td>
<td class=""></td>
<td class=""></td>
<td class=""></td>
<td class=""></td>
</tr>
<tr class= "salatContent">
<td class="">Salat</td>
<td class="tg-031e" colspan="5"></td>
</tr>
</table>
</div>
</body>
</html>