I would like to change the value of a textarea and an input field. The whole thing should happen with an onclick. Unfortunately, my approach seems to be wrong. I would be happy about tips.
<textarea class="input" name="adresse" readonly="readonly" id="street" value="test"></textarea>
<input style="width:130px;text-align: left" class="input" type="text" name="kundennr" id="kundennr" value="10000">
<?php
$sql = "SELECT * FROM `kunde` ORDER BY `kundennummer` ASC";
foreach ($dbh->query($sql) as $nav) {
$address = $nav['adresse'];
$name = $nav['kundennummer'];
echo "
<input type='text' name='textfield' id='textfield$name' value='$address'>
<a> | Kundennr: </a><a href='#' id='text' onclick='updateTxt(this);' >$name</a><br>
";
}
?>
</div>
</div>
<script>
function updateTxt(el)
{
var inhalt = el.text;
var field2 = document.getElementById('textfield'+inhalt).value;
document.getElementById('kundennr').value =inhalt;
document.getElementById('street').innerHTML = field2;
}
</script>
Update:
Thanks to all I found the solution