Merge branch 'master' of https://git.schoffit.net/structix/intecsync
This commit is contained in:
@@ -24,7 +24,6 @@
|
||||
}
|
||||
alert("Die Brötchen kosten " + result + "€");
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
|
77
uebung3/farbenlehre.html
Normal file
77
uebung3/farbenlehre.html
Normal file
@@ -0,0 +1,77 @@
|
||||
<!DOCTYPE html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Farbenlehre</title>
|
||||
<style>
|
||||
table {
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
table, th, td {
|
||||
border: 1px solid black;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<label for="rot">Rot: </label>
|
||||
<input id="rot" name="rot" type="number">
|
||||
</br>
|
||||
<label for="gruen">Grün: </label>
|
||||
<input id="gruen" name="gruen" type="number">
|
||||
</br>
|
||||
<label for="blau">Blau: </label>
|
||||
<input id="blau" name="blue" type="number">
|
||||
</br>
|
||||
<button id="calcbutton">Berechnen</button>
|
||||
</br>
|
||||
|
||||
<table id="farben">
|
||||
<tr>
|
||||
<td><b>Rot</b></td>
|
||||
<td><b>Grün</b></td>
|
||||
<td><b>Blau</b></td>
|
||||
<td><b>Farbwert</b></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<script>
|
||||
let btn = document.getElementById("calcbutton");
|
||||
let rot = document.getElementById("rot");
|
||||
let gruen = document.getElementById("gruen");
|
||||
let blau = document.getElementById("blau");
|
||||
|
||||
btn.addEventListener("click", updateTable);
|
||||
|
||||
function toHex(farbstring) {
|
||||
let tempint = parseInt(farbstring);
|
||||
let temphex = tempint.toString(16);
|
||||
if (tempint < 16) {
|
||||
//hex Zahl hat nur eine Stelle
|
||||
temphex = "0" + temphex;
|
||||
}
|
||||
return temphex.toUpperCase();
|
||||
}
|
||||
|
||||
function updateTable() {
|
||||
let table = document.getElementById("farben");
|
||||
let row = table.insertRow(1);
|
||||
let cell1 = row.insertCell(0);
|
||||
let cell2 = row.insertCell(1);
|
||||
let cell3 = row.insertCell(2);
|
||||
let cell4 = row.insertCell(3);
|
||||
|
||||
let r = rot.value;
|
||||
let g = gruen.value;
|
||||
let b = blau.value;
|
||||
|
||||
cell1.innerHTML = toHex(r);
|
||||
cell2.innerHTML = toHex(g);
|
||||
cell3.innerHTML = toHex(b);
|
||||
let farbcode = "#" + toHex(r) + toHex(g) + toHex(b);
|
||||
cell4.innerHTML = farbcode;
|
||||
cell4.style.backgroundColor = farbcode;
|
||||
}
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
@@ -5,10 +5,20 @@
|
||||
<body style="text-align: center;">
|
||||
<script>
|
||||
let arr = Array.from({length: 10}, () => Math.random().toFixed(2));
|
||||
let min = arr[0];
|
||||
let max = arr[0];
|
||||
for (i = 0; i < arr.length; i++) {
|
||||
if (arr[i] < min) {
|
||||
min = arr[i];
|
||||
}
|
||||
if (arr[i] > max) {
|
||||
max = arr[i];
|
||||
}
|
||||
}
|
||||
document.write("<h1>Min-Max-Finder</h1>");
|
||||
document.write(arr + "</br>");
|
||||
document.write("Minimum: " + Math.min(...arr) + "</br>");
|
||||
document.write("Maximum: " + Math.max(...arr));
|
||||
document.write("Minimum: " + min + "</br>");
|
||||
document.write("Maximum: " + max);
|
||||
</script>
|
||||
</body>
|
||||
|
||||
|
104
uebung3/tabellenmanipulation.html
Normal file
104
uebung3/tabellenmanipulation.html
Normal file
@@ -0,0 +1,104 @@
|
||||
<!DOCTYPE html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Tabellenmanipulation</title>
|
||||
<style>
|
||||
table {
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
table, th, td {
|
||||
border: 1px solid black;
|
||||
}
|
||||
p {
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<button id="inscol" onclick="inscolumn()">Spalte hinzufügen</button>
|
||||
<button id="delcol" onclick="delcolumn()">Spalte entfernen</button>
|
||||
<button id="insrow" onclick="insrow()">Zeile hinzufügen</button>
|
||||
<button id="delrow" onclick="delrow()">Zeile entfernen</button>
|
||||
<p id="dimension"></p>
|
||||
<table id="table"></table>
|
||||
|
||||
<script>
|
||||
let table = document.getElementById("table");
|
||||
let tableBody = document.createElement("tableBody");
|
||||
let counter = document.getElementById("dimension");
|
||||
let colcount = 0;
|
||||
let rowcount = 0;
|
||||
let fieldval = "Feld";
|
||||
|
||||
function updateDimension() {
|
||||
counter.innerHTML = "Dimension: " + rowcount + " x " + colcount;
|
||||
}
|
||||
|
||||
function insrow() {
|
||||
let row = document.createElement("tr");
|
||||
tableBody.appendChild(row);
|
||||
table.appendChild(tableBody);
|
||||
if(colcount != 0){
|
||||
for(x=0; x<colcount; x++){
|
||||
let firstChild = tableBody.children[rowcount];
|
||||
let cell = document.createElement("td");
|
||||
let text = document.createTextNode(fieldval);
|
||||
cell.appendChild(text);
|
||||
firstChild.appendChild(cell);
|
||||
}
|
||||
}
|
||||
rowcount++;
|
||||
updateDimension();
|
||||
}
|
||||
|
||||
function delrow(){
|
||||
if(rowcount < 1){
|
||||
alert("Es kann keine weitere Zeile entfernt werden.");
|
||||
} else {
|
||||
let firstChild = tableBody.children[0];
|
||||
tableBody.removeChild(firstChild);
|
||||
rowcount--;
|
||||
updateDimension();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function inscolumn(){
|
||||
if(rowcount==1){
|
||||
let firstChild = tableBody.children[0];
|
||||
let cell = document.createElement("td");
|
||||
let text = document.createTextNode(fieldval);
|
||||
cell.appendChild(text);
|
||||
firstChild.appendChild(cell);
|
||||
} else {
|
||||
for(i=0; i<rowcount; i++){
|
||||
let firstChild = tableBody.children[i];
|
||||
let cell = document.createElement("td");
|
||||
let text = document.createTextNode(fieldval);
|
||||
cell.appendChild(text);
|
||||
firstChild.appendChild(cell);
|
||||
}
|
||||
}
|
||||
colcount++;
|
||||
updateDimension();
|
||||
}
|
||||
|
||||
function delcolumn(){
|
||||
if(colcount < 1){
|
||||
alert("Es kann keine weitere Zeile entfernt werden.");
|
||||
} else {
|
||||
for(i=0; i < rowcount; i++){
|
||||
let firstChild = tableBody.children[i];
|
||||
firstChild.deleteCell(0);
|
||||
}
|
||||
colcount--;
|
||||
updateDimension();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
Reference in New Issue
Block a user