-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjs18.html
More file actions
67 lines (63 loc) · 1.29 KB
/
js18.html
File metadata and controls
67 lines (63 loc) · 1.29 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<!--Add and remove items between two multiple selection boxes -->
<!DOCTYPE html>
<html>
<head>
<title>js18</title>
<script type="text/javascript">
function fremove()
{
x = document.getElementById("main");
y=document.getElementById("selected");
for (var i=0; i<=x.length; i++)
{
var option = document.createElement("option");
option.text = x.options[x.selectedIndex].value;
x.remove(x.selectedIndex);
y.add(option);
}
}
function fadd()
{
x = document.getElementById("main");
y=document.getElementById("selected");
for (var i=0; i<=y.length; i++)
{
var option = document.createElement("option");
option.text = y.options[y.selectedIndex].value;
y.remove(y.selectedIndex);
x.add(option);
}
}
</script>
</head>
<body>
<table>
<tr>
<td>
<select id="main" multiple size="8">
<option selected disabled>select items</option>
<option>a</option>
<option>b</option>
<option>c</option>
<option>d</option>
<option>e</option>
<option>f</option>
<option>g</option>
</select>
</td>
<td>
<select id="selected" multiple size="8">
<option selected disabled>selected items</option>
</select>
</td>
<tr>
<td>
<button onclick="fremove();">add items to cart</button>
</td>
<td>
<button onclick="fadd();">remove items from cart</button>
</td>
</tr>
</table>
</body>
</html>