处理即时文本框值

Is it possible to have a text input field which displays somewhere else (e.g. in a div) what its content is on change?

Example: I type 1, so 1 is outputted somewhere on my screen immediatly, then I type 2 and the previous value is now updated to 12.

html

<input type="text" id="inputField" />
<div id="screen"></div>

script

document.getElementById('inputField').onkeyup = function(){
document.getElementById('screen').innerHTML = this.value;
};

The code is good but I want the screen's inner html value to be format in php. Example: the screen value is stored into $screen and then I'd echo the output where i want into the screen

[I want (echo "$screen";) like in php I will type the number in text box means it echo the value immediately used with php format]

how to store a screen value into variable $screen

<html  >
<head>
    <script type="text/javascript">
        function KeyHandler() {
            var result = document.getElementById('result');
            result.innerHTML=document.getElementById('txtInput').value;

        }
    </script>
</head>
<body >
<div>Type something.........</div><br />
<input type='text' id='txtInput'onkeyup="KeyHandler()" />

<br/>
Result:
<div id="result"></div>
</body>
</html>

Try this,

HTML

<input type="text" id="addInput" />
<div id="showdata"></div>

SCRIPT

$('input#addInput').on('keyup',function(){
   $('div#showdata').html($(this).val());
});

You can do this by little javascript code, (assuming that you need to display text entered in a input field on a html div), So try this in html,

<input type="text" id="inputField" />
<div id="screen"></div>

and bind a onkeyup event to the input field by which you can get the text when someone enters into it. So your javascript will be,

document.getElementById('inputField').onkeyup = function(){
    document.getElementById('screen').innerHTML = this.value;
};

Working demo here and you can post the input field value to any php script by including a form element in your html code.