---
title: "让下拉列表select可编辑的简便方法 2"
author: "hecal"
date: "2010-01-21T13:41:00Z"
tags: []
categories: ["Web前端"]
slug: "select-2"
draft: false
lastmod: "2011-12-08T10:52:48Z"
id: 1296495
url: "https://hecal.iteye.com/blog/1296495"
---

下拉列表select可编辑的简便方法 1:

 

&lt;div style="position:relative;"&gt;  
&lt;span style="margin-left:100px;width:18px;overflow:hidden;"&gt;  
&lt;select id='FROM\_VALUE' style="width:118px;margin-left:-100px" onchange="this.parentNode.nextSibling.value=this.value"&gt;  
&lt;option value="aaaa"&gt; aaaa &lt;/option&gt;  
&lt;option value="bbbb"&gt; bbbb &lt;/option&gt;  
&lt;option value="cccc"&gt; ccccc &lt;/option&gt;  
&lt;/select&gt;&lt;/span&gt;&lt;input name="FROM\_VALUE" style="width:100px;position:absolute;left:0px;"&gt;  
&lt;/div&gt;

 

 

下拉列表select可编辑的简便方法 2:

 

&lt;div style="position:relative;"&gt;  
&lt;span style="margin-left:100px;width:18px;overflow:hidden;"&gt;  
&lt;select name="FROM\_VALUE" id='FROM\_VALUE' style="width:118px;margin-left:-100px" &gt;  
&lt;/select&gt;&lt;/span&gt;&lt;input name="FROM\_VALUE\_HID" id="FROM\_VALUE\_HID" style="width:100px;position:absolute;left:0px;"&gt;  
&lt;/div&gt;

 

var from\_sel=document.getElementById('FROM\_VALUE');  
var from\_hid=document.getElementById('FROM\_VALUE\_HID');  
from\_hid.type = "hidden";  
hasElement = false;

if (hasElement == false) {  
from\_sel.name = "FROM\_VALUE\_SEL";  
from\_hid.name = "FROM\_VALUE";  
from\_hid.type = "text";  
} else {  
from\_sel.name = "FROM\_VALUE";  
from\_hid.name = "FROM\_VALUE\_HID";  
from\_hid.type = "hidden";  
}