<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script>
let tp = null; let xmax = null; let xopn = null; let op0 = null; let sh0 = null;
function createData() {
const data = {
tp: +inpX.value,
xmax: +inpY.value,
xopn: +inpZ.value,
op0: inpArr1.value.split(",").map(Number),
sh0: inpArr2.value.split(",").map(Number)
}
console.log(data);
return data
}
function initValues() {
const data = createData()
let tp = data.tp
let xmax = data.xmax
let xopn = data.xopn
let op0 = data.op0
let sh0 = data.sh0
console.log(tp);
console.log(xmax);
console.log(xopn);
console.log(op0);
console.log(sh0);
}
</script>
<title>Example 2</title>
</head>
<body>
<div class="container">
<div class="row row-x">
<span>Введите значение Х</span>
<input id="x" type="text">
</div>
<div class="row row-y">
<span>Введите значение Y</span>
<input id="y" type="text">
</div>
<div class="row row-z">
<span>Введите значение Z</span>
<input id="z" type="text">
</div>
<div class="row row-arr-1">
<input id="inp-arr-1" type="text" placeholder="Значения массива через запятую, без пробелов">
</div>
<div class="row row-arr-2">
<input id="inp-arr-2" type="text" placeholder="Значения массива через запятую, без пробелов">
</div>
<div class="row">
<button id="save">Сохранить</button>
</div>
</div>
<script>
const inpX = document.getElementById('x');
console.log(inpX)
const inpY = document.getElementById('y')
console.log(inpY)
const inpZ = document.getElementById('z')
console.log(inpZ)
const inpArr1 = document.getElementById('inp-arr-1')
console.log(inpArr1)
const inpArr2 = document.getElementById('inp-arr-2')
console.log(inpArr2)
const inputs = document.querySelectorAll('input')
console.log(inputs)
const btnSave = document.getElementById('save')
console.log(btnSave)
btnSave.addEventListener('click', () => {
initValues()
})
console.log(tp * 2);
</script>
</body>
</html>