กล่องเลื่อนลงที่แก้ไขได้ - HTML
การคัดลอกรหัสมีดังนี้:
<div style = "ตำแหน่ง: ญาติ">
<เลือก onChange = "document.getElementById ('input'). value = this.value">
<ตัวเลือกค่า = "คลาส A"> คลาส A </potion>
<ตัวเลือกค่า = "คลาส B"> คลาส B </potion>
<ตัวเลือกค่า = "คลาส C"> คลาส C </potion>
<ตัวเลือกค่า = "คลาส D"> คลาส D </portion>
</เลือก>
<อินพุต id = "อินพุต" ชื่อ = "อินพุต" สไตล์ = "ตำแหน่ง: สัมบูรณ์; ความกว้าง: 99px; ความสูง: 16px; ซ้าย: 1px; ด้านบน: 2px; ขอบด้านล่าง: 0px; ชายแดน-ขวา: 0px; ชายแดนซ้าย: 0px;
</div>
Box-Js แบบเลื่อนลงที่แก้ไขได้
การคัดลอกรหัสมีดังนี้:
<html>
<head>
<meta name = "generator" content = "Microsoft FrontPage 5.0">
<meta name = "progid" content = "frontpage.editor.document">
<meta http-equiv = "content-type" content = "text/html; charset = gb2312">>
<title> กล่องเลื่อนลงที่แก้ไขได้ </title>
</head>
<body>
<table style = "border: 2px ontset; พื้นหลังสี:#d2e8ff" allign = "center">
<tr>
<td align = "center">
<select name = "fason">
<ตัวเลือกค่า = "กล่องแบบเลื่อนลงที่แก้ไขได้"> กล่องเลื่อนลงที่แก้ไขได้ </porture>
<ตัวเลือกค่า = "ผู้เขียน"> ผู้แต่ง </potion>
</เลือก>
</td>
</tr>
</table>
<ภาษาสคริปต์ = "JavaScript">
ฟังก์ชั่น combox (obj, select) {
this.obj = obj
this.name = select;
this.select = document.getElementsByName (เลือก) [0];
/*กล่องดรอปดาวน์ที่จะแปลง*/
-
/*เริ่มต้นวัตถุ*/
combox.prototype.init = function () {
var inputbox = "<input name = 'combox _"+this.name+"' onChange = '"+this.obj+"ค้นหา ()'"
InputBox+= "style = 'ตำแหน่ง: สัมบูรณ์; ความกว้าง:"+(this.select.offsetWidth-16)+"; ความสูง:"+this.select.offSetheight+"; ซ้าย:"+getl (this.select)+"; top:" gett (this.select)+"'>"
document.write (inputbox)
ด้วย (this.select.style) {
ซ้าย = getL (this.select)
top = gett (this.select)
ตำแหน่ง = "สัมบูรณ์"
clip = "rect (0"+(this.select.offsetWidth)+""+this.select.offsetheight+""+(this.select.offsetWidth-18)+")"
/*ตัดกล่องดึงลง*/
-
this.select.onchange = ฟังก์ชั่นใหม่ (this.obj+". เปลี่ยน ()")
this.change ()
-
/*การเริ่มต้นสิ้นสุดลง*/
///////////////////////////ife ฯ
combox.prototype.find = function () {
/*เมื่อค้นหาค่าของกล่องอินพุตกล่องแบบเลื่อนลงจะถูกวางตำแหน่งโดยอัตโนมัติ*/
var inputbox = document.getElementsByName ("combox _"+this.name) [0]
ด้วย (this.select) {
สำหรับ (i = 0; i <opotions.length; i ++)
if (ตัวเลือก [i] .text.indexof (inputbox.value) == 0) {
selectedIndex = i
this.change ();
หยุดพัก;
-
-
-
combox.prototype.change = function () {
/*กำหนดเหตุการณ์ onchange ของกล่องแบบเลื่อนลง*/
var inputbox = document.getElementsByName ("combox _"+this.name) [0]
inputbox.value = this.select.options [this.select.selectedIndex] .Text;
ด้วย (inputbox) {select (); focus ()};
-
-
/*ฟังก์ชั่นการวางตำแหน่งทั่วไป (รับพิกัดสัมบูรณ์ของการควบคุม)*/
ฟังก์ชั่น getl (e) {
var l = e.offsetleft;
ในขณะที่ (e = e.offsetparent) l+= e.offsetleft;
กลับ l
-
ฟังก์ชั่น gett (e) {
var t = e.offsettop;
ในขณะที่ (e = e.offsetParent) t+= e.offSettop;
กลับ t
-
/*เสร็จ*/
</script>
<ภาษาสคริปต์ = "JavaScript">
var a = new combox ("a", "fason")
a.init ()
</script>
</body>
</html>