Displaying text

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pavanponnapalli
    New Member
    • May 2008
    • 51

    Displaying text

    hi,
    There are two textboxes in a form. The second textbox's data is to be displayed on the same page, character by character . Is it possible using any Event in Javascript? Suppose i entered Bytes in the textbox. When i type 'B' in the textbox it should be displayed on the top of the page as B, again as i enter 'y' in the textbox it should be dispalyed immediately after B as 'By' so on and so forth. I don't have any button,suppose. Then my questions are:
    1) Is it possible?
    2) If possible, then how?

    Could anyone explain me?
    cheers,
    pavan
  • mrhoo
    Contributor
    • Jun 2006
    • 428

    #2
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
    <html lang= "en">

    <head>
    <title>Input Echo</title>

    <script type= "text/javascript">
    Code:
    window.onload= function(){
    	var who=document.getElementsByName('in_2')[0];
    	who.onkeyup= who.onchange=function(e){
    	    e= window.event||e;
    	    var v= e.srcElement || e.target;	    	
    		document.getElementById("echotext").lastChild.data=v.value;
    	}
    }
    </script>
    </head>
    <body>
    <h1>Input echo</h1>
    <h2 id="echotext">< span>Text:</span> </h2>
    <form id= "form_1" action='' onsubmit="retur n false">
    <p>
    <label>No echo:<input name= "in_1" type="text"></label>
    <label>Echo This:<input name= "in_2" type="text"></label>
    </p>
    </form>
    </body>
    </html>

    Comment

    Working...