1
<html>
2
<body>
3
<form name="aa">
4
<table align="center">
5
<tr>
6
<td>
7
<select name="xuanze" size="6" style="80px">
8
<option value="海淀">海淀</option>
9
<option value="朝阳">朝阳</option>
10
<option value="东城">东城</option>
11
<option value="西城">西城</option>
12
<option value="宣武">宣武</option>
13
<option value="丰台">丰台</option>
14
</select>
15
</td>
16
<td align="center">
17
<input type="button" value="添加>>" onclick="javascript:add()"/>
18
<br>
19
<input type="button" value="<<删除" onclick="javascript:del()"/>
20
</td>
21
<td>
22
<select name="xuanzhong" size="6" style="80px"></select>
23
</td>
24
</tr>
25
26
</table>
27
</form>
28
</body>
29
<script type="text/javascript">
30
function isexist(va){
31
var ee = false;
32
for(var i=0;i<document.aa.xuanzhong.options.length;i++)
33
if(document.aa.xuanzhong.options[i].value==va)
34
{ ee=true; break;}
35
return ee;
36
}
37
function add(){//添加
38
for(var i=0;i<document.aa.xuanze.options.length;i++)
39
if(document.aa.xuanze.options[i].selected) {
40
if(!isexist(document.aa.xuanze.options[i].value)) //是否已经添加??
41
document.aa.xuanzhong.options[document.aa.xuanzhong.options.length]
42
= new Option(document.aa.xuanze.options[i].value,document.aa.xuanze.options[i].text);
43
}
44
}
45
function del(){
46
for(var i=document.aa.xuanzhong.options.length-1;i>=0;i--)
47
if(document.aa.xuanzhong.options[i].selected)
48
document.aa.xuanzhong.options[i] = null; //删除一个项目
49
50
}
51
</script>
52
</html>

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
