Click here to Skip to main content
15,914,642 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a text box and a button.whatever i write in the text box it should be displayed on a label.what will be my code
Posted

use onChange event of the textbox if you want to display on label on textchange of the textbox

or you can use button's onClick event

HTML
function Test(value){
document.getElementById('span or label Id').innerHTML=value;
}

<input type="text"  önchange="Test(this.value" />
 
Share this answer
 
v2
This is bit easy. on button click you need to set text to label.
write a javascript under <head> tag

JavaScript
<script language="Javascript">
function setLabel()
{
  //set label value by collecting text from textbox
  document.getElementById("Label1").innerHTML = document.getElementById("Txt1").value;
  return false;
}
</script>
</script>


call above javascript function on button click
ASP.NET
<asp:button id="BtnId1" runat="Server" value="SerText" onclientclick="return setLabel()">
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900