مربع منسد قابلة للتحرير - HTML
نسخة الكود كما يلي:
<div style = "الموضع: قريب ؛">
<حدد OnChange = "document.getElementById ('input'). value = this.value">
<Option Value = "Class A"> Class A </forte>
<Option Value = "Class B"> Class B </soph>
<Option Value = "Class C"> Class C </Option>
<Option Value = "Class D"> Class D </forte>
</select>
<input id = "input" name = "input" style = "الموضع: المطلق ؛ العرض: 99px ؛ الارتفاع: 16px ؛ اليسار: 1px ؛ الأعلى: 2px ؛ bord-bottom: 0px ؛ اليمين الحدودي: 0px ؛ الحدود اليسار: 0px ؛
</div>
قابلة للتحرير منسد مربع-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 estet ؛ background-color:#d2e8ff" align = "center">
<tr>
<td align = "center">
<حدد name = "fason">
<Option Value = "مربع المنسدلة"
<Option Value = "Author"> المؤلف </option>
</select>
</td>
</r>
</table>
<script language = "javaScript">
وظيفة combox (obj ، حدد) {
this.obj = obj
this.name = select ؛
this.select = document.getElementSbyName (select) [0] ؛
/*المربع المنسدل المراد تحويله*/
}
/*تهيئة الكائن*/
combox.prototype.init = function () {
var inputbox = "<input name = 'combox _"+this.name+"' 'onChange ='"+this.obj+". find () '"
inpoxbox+= "style = 'الموضع: مطلق ؛ العرض:"+(this.select.offsetwidth-16)+"
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 ()
}
/*تنتهي التهيئة*/
//////////////////كائن تعريف حدث ////////////
combox.prototype.find = function () {
/*عند البحث في قيمة مربع الإدخال ، سيتم وضع المربع المنسدل تلقائيًا*/
var inputbox = document.getElementSbyName ("combox _"+this.name) [0]
مع (this.select) {
لـ (i = 0 ؛ i <options.length ؛ i ++)
if (خيارات [i] .text.indexof (inputbox.value) == 0) {
SelectionIndex = i
this.Change () ؛
استراحة؛
}
}
}
combox.prototype.change = function () {
/*تحديد حدث onChange للمربع المنسدل*/
var inputbox = document.getElementSbyName ("combox _"+this.name) [0]
inpoxbox.value = this.select.options [this.select.SelectedIndex] .text ؛
مع (inputbox) {select () ؛ Focus ()} ؛
}
////////////////////////////
/*وظيفة تحديد المواقع الشائعة (احصل على الإحداثيات المطلقة للتحكم)*/
وظيفة getl (e) {
var l = e.offsetleft ؛
بينما (e = e.offsetParent) l+= e.offSetLeft ؛
العودة ل
}
وظيفة gett (e) {
var t = e.offsettop ؛
بينما (e = e.offsetParent) t+= e.offsettop ؛
العودة ر
}
/*ينهي*/
</script>
<script language = "javaScript">
var a = new combox ("a" ، "fason")
A.Init ()
</script>
</body>
</html>