I am new to this and have almost achieved what i would like to achieve. I want the complete output text (which comprises of plain text + text from the function to only appear once a button is clicked. At the moment the plain text appears immediately and the text from the function appears as soon as the text box is populated.
i have tried to use: <button type="button" onclick="updateTxt()">Run</button> but cant get it to work. Please help
<html>
<script type="text/javascript">
function updateTxt(field,toField, toField2){
var field = document.getElementById(field);
var toField = document.getElementById(toField);
var toField2 = document.getElementById(toField2);
toField.innerHTML=field.value;
toField2.innerHTML=field.value;
}
</script>
Name: <input type="text" id="box1" onkeyup="updateTxt('box1','txt1', 'txt111');"></BR>
Country: <input type="text" id="box2" onkeyup="updateTxt('box2','txt2');"></BR>
My name is <span id="txt1"></span>, and i named my son <span id="txt111"></span> too. We live in <span id="txt2"></span>
</html>