-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjs15.html
More file actions
50 lines (48 loc) · 1.22 KB
/
js15.html
File metadata and controls
50 lines (48 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<!--A two dimensional array containing Employee id, Name and Designation in JavaScript. Populate employee ids in a drop down list. On selecting an ID, Name and Designation should be appended to the table in the page-->
<!DOCTYPE html>
<html>
<head>
<title>js15</title>
<script type="text/javascript">
function fun()
{
var emp = { 1: { name: 'abc', designation: 'manager' }, 2: { name:'alice' , designation: 'director' },
3: { name: 'ghi', designation: 'asst.mngr' },4: { name: 'jkl', designation: 'employee' } };
id=document.getElementById('id').value;
document.getElementsByName("nam")[0].value=emp[id]["name"];
document.getElementsByName("dest")[0].value=emp[id]["designation"];
}
</script>
</head>
<body>
<table>
<tr>
<td>employee id:</td>
<td>
<select id="id" >
<option selected disabled>employee id</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
</td>
<td>
<input type="submit" value="find" name="ok" onclick="fun()">
</td>
</tr>
<tr>
<td>name:</td>
<td>
<label id="lb1"><input type="text" value="name" name="nam"></label>
</td>
</tr>
<tr>
<td>destination:</td>
<td>
<label id="lb2"><input type="text" value="dest" name="dest"></label>
</td>
</tr>
</table>
</body>
</html>