Html可以輸入的下拉框設計

來源:互聯網
上載者:User

標籤:document   type   onchange   軟體   手動   字型   text   注意   htm   

實現:設計出一個可以手動輸入也可以下拉選擇的控制項。

思路:

  在下拉控制項的上方放置一個文字框,但是width要注意(顯示出下拉按鈕),所以下拉框和文字框的position屬性都是absolute,下拉框選擇ongchange事件,把選中的下拉項的值賦值給文字框,這時這個文字框既可以輸入也可以被下拉選擇(取下拉框的值)最終取文字框中的值。

    <table cellspacing="0" cellpadding="0" width="100%" border="0">        <tr>            <td align="left">                <!--select標籤和input外面的span標籤的格式是為了使兩個位置在同一位置,控制位置-->                <span style="position: absolute; border: 1pt solid #c1c1c1; overflow: hidden; width: 188px;                    height: 19px; clip: rect(-1px 190px 190px 170px);">                    <select name="aabb" id="aabb" style="width: 190px; height: 20px; margin: -2px;" onchange="javascript:document.getElementById(‘ccdd‘).value=document.getElementById(‘aabb‘).options[document.getElementById(‘aabb‘).selectedIndex].value;">                        <!--下面的option的樣式是為了使字型為灰色,只是視覺問題,看起來像是注釋一樣-->                        <option value="" style="color: #c2c2c2;">---請選擇---</option>                        <option value="閑人書庫">閑人書庫</option>                        <option value="閑人BLOG">閑人BLOG</option>                        <option value="閑人設計">閑人設計</option>                        <option value="閑人軟體">閑人軟體</option>                    </select>                </span><span style="position: absolute; border-top: 1pt solid #c1c1c1; border-left: 1pt solid #c1c1c1;                    border-bottom: 1pt solid #c1c1c1; width: 170px; height: 19px;">                    <input type="text" name="ccdd" id="ccdd" value="輸入或選擇" style="width: 170px;                        height: 19px; border: 0pt;"/>                </span>            </td>        </tr>    </table>

 

Html可以輸入的下拉框設計

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.