Java Script


JavaScript Tutorial


Admission Enquiry Form


How to Concat Name Entered in different Textboxes?

Example :

<html>
<head>
<title>Firstname Lastname Concatinated</title>
<style>
#q3{background-color:red;}
table{background-color:lightgrey;}
</style>
<script>
function join()
{
var c_name=document.getElementById("txt_firstname").value+" "+document.getElementById("txt_lastname").value;
document.getElementById("txt_concat").value=c_name;
}
</script>
</head>
<body>
<h2 id="q3">Q3.Enter firstname in first textbox, Enter secondname in second textbox then concat firstname and lastname in third textbox.</h2>
<table>
<tr><td><label>Enter Firstname:</label></td><td><input type="text" id="txt_firstname"></td></tr>
<tr><td><label>Enter Secondname:</label></td><td><input type="text" id="txt_lastname"></td></tr>
<tr><td><label>Concatinated name:</label></td><td><input type="text" id="txt_concat"></td></tr>
<tr><td></td><td><input type="button" value="click" onclick="join()"></td></tr>
</table>
</body>
</html>

Firstname Lastname Concatinated

Q3.Enter firstname in first textbox, Enter lastname in second textbox then concat firstname and lastname in third textbox.