interviews.dotnetthread.com

↑ Grab this Headline Animator

Thursday, November 20, 2008

How to type a character or number or anything at a time into two textbox's?

Suppose we will take the two textBox fields like below

<body>
<form id="form1" runat="server">
<div>
<input type="text" id="T1" onkeyup="makeSame();clear();" />
<input type="text" id="T2" />
</div>
</form>
</body>

Then we will write the function for typing character at a time into textbox and call the function on the first textbox onkeyup event as well as to clear a character at a time.

function makeSame()
{

document.getElementById('T2').value= document.getElementById('T1').value;


}
function clear()
{
var num1=document.getElementById('T1').value;
var num2=document.getElementById('T2').value;
if(document.getElementById('T1').value=="")
{
if(document.getElementById('T2').value=="")
{
document.getElementById('T2').value="";
return;
}
}
var num3=parseInt(num2)+1;
document.getElementById('T2').value=num3;
}

Submit this story to DotNetKicks

2 comments:

ur said...

where i sfunction "sum()"

Anonymous said...

just ignore that(Sum() function). No need of that onchange event handler.

Post a Comment

Post your comments/questions/feedback for this Article.

 

Latest Articles