javascript组合搜索浏览器

 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2 <html xmlns="http://www.w3.org/1999/xhtml">
3 <head>
4 <title></title>
5 <style type="text/css">
6 #btnSerch
7 {
8 height: 21px;
9 width: 100px;
10 }
11 #select
12 {
13 width: 130px;
14 }
15 #inpuTxtBox
16 {
17 width: 223px;
18 }
19 </style>
20 <script type="text/javascript">
21
22 function btnSerch_onclick() {
23 var selectObject = document.getElementById("select");
24 var selectOptions = selectObject.options;
25 var index = 0;
26 index = selectObject.selectedIndex;
27
28 document.forms[1 + index].elements[0].value = document.getElementById("inpuTxtBox").value;
29
30 document.forms[1+index].submit();
31
32 }
33
34 </script>
35 </head>
36
37 <body>
38 <form name="inputForm">
39
40
41
42
43
44
45 查找内容:<input type="text" id="inpuTxtBox" />
46 搜索引擎:<select id="select">
47 <option value="001">baidu</option>
48 <option value="002">Google</option>
49 </select>
50
51 <input type="button" id="btnSerch" value="搜 索" onclick="btnSerch_onclick()" />
52
53 </form>
54
55 <form action="http://www.baidu.com/s">
56 <input type="hidden" name="wd" value="" />
57 </form>
58 <form action="http://www.google.com/search">
59 <input type="hidden" name="q" value="" />
60 </form>
61 </body>
62 </html>

 

posted @ 2012-03-26 10:30  星辰手  阅读(308)  评论(0编辑  收藏  举报