0

Can I allocate a text box in the html page itself to mirror console.log* ?

<html><body>
<script type="text/javascript">

function btnclick(id) 
{
    console.log(document.getElementById(id).value);
}
</script>
<table>
<td><input type="button" value="7" id="btn7" onclick="btnclick('btn7');"/></td>
<td><input type="button" value="8" id="btn8" onclick="btnclick('btn8');"/></td>
<tr>
<td><input type="button" value="4" id="btn4" onclick="btnclick('btn4');"/></td>
<td><input type="button" value="5" id="btn5" onclick="btnclick('btn5');"/></td>
</tr>
</table></body></html>

*console.log here simply echoes the pressed number

OrenIshShalom
  • 5,974
  • 9
  • 37
  • 87
  • Where's your text box? You can just add the textbox update to `btnclick()` – mykaf Oct 14 '22 at 18:14
  • @mykaf not sure what you mean – OrenIshShalom Oct 14 '22 at 18:18
  • a.) there is no textbox in the html presented. b.) once you have said textbox, you'll need to write code to update your textbox. `console.log()` itself won't update your textbox, but you can replace `console.log()` with `btnclick()` or whatever function to quickly do both. – mykaf Oct 14 '22 at 18:24
  • @MosheKatz I don't want a stack of values - I want to see just the *last* logged line – OrenIshShalom Oct 14 '22 at 18:25

0 Answers0