I'm new to Javascript. I would like to include more than two js(javascript) file. When I type something(text) on the input filed particuar function is not executing.
only last js file(three.js) is working. what I'm missing please let me know.
my code:
Text.html
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="UTF-8">
<title>Myweb</title>
</head>
<script src="one.js" type="text/javascript"></script>
<script src="two.js" type="text/javascript"></script>
<script src="three.js" type="text/javascript"></script>
<style>
</style>
<body>
<h1>Hello World!</h1>
<input type='text' placeholder='enter name' id='name'><br><br>
<input type='text' placeholder='enter uname' id='uname'><br><br>
<input type='text' placeholder='enter fname' id='fname'>
</body>
</html>
one.js
window.onload = initPage;
function initPage() {
document.getElementById("name").onchange=namefun;
}
function namefun(){
var name=document.getElementById("name").value;
alert("name:"+name);
}
two.js
window.onload = initPage;
function initPage() {
document.getElementById("uname").onchange=unamefun;
}
function unamefun(){
var uname=document.getElementById("uname").value;
alert("uname:"+uname);
}
three.js
window.onload = initPage;
function initPage() {
document.getElementById("fname").onchange=fnamefun;
}
function fnamefun(){
var fname=document.getElementById("fname").value;
alert("fname:"+fname);
}
Any help
Thanks