I created a page with a form, where you can enter a name. When you submit the name, the name is stored under the name "bezeichnung". Now i want to use the the input "bezeichnung" as a button label. And append it to the body of the page.
This is the form:
<head>
<link rel="stylesheet" href="\User\stl.css"/>
</head>
<body>
<h1> Neue Station hinzufügen</h1>
<form id="stationenformular" name="stationenformular" action="indexAktualisierung.html" method="get">
<div>
<label for="bezeichnung">Bezeichung der neuen Station:</label>
<input type="text" id="bezeichnung" name="bezeichung" />
</div>
<br><br>
<div>
<label for="ipadresse"> IP Adresse des Raspberry Pi:</label>
<input type="text" id="ipadresse" name="ipadresse"/text>
</div>
<div>
<br>
<input type="submit" value="Abschicken"/>
</div>
</form>
</body>
</head>
and this the function in another html script:
var x = document.getElementsByName("bezeichnung");
var btn = document.createElement("BUTTON"); // Create a <button> element
var t = document.createTextNode(x); // Create a text node
btn.appendChild(t); // Append the text to <button>
document.body.appendChild(btn);
<input type="text" id="bezeichnung" name="bezeichung" />
should be<input type="text" id="bezeichnung" name="bezeichnung" />
– Yvonne Aburrow