2013-12-12 205 views
0

您好我想顯示下拉值所選的文本框中的值。假設我選擇了sql 我得到了類似於jdbc的值:mysql:// localhost/lportal?useUnicode = true & characterEncoding = UTF-8 & useFastDateParsing = falsein jdbc url textbox.com.mysql.jdbc.Driver驅動程序類文本框中的驅動程序名。 這種類型的代碼我想如何在文本框中選擇下拉列表值的值?

 <form> 
       <table> 
        <tr> 
         <td>Database Type</td> 
        </tr> 
        <tr> 
         <td><select name="Database Type" onclick="fillData()" id="sel_value"> 
           <option value="DB2">DB2</option> 
           <option value="Derby">Derby</option> 
           <option value="Hypersonic">Hypersonic</option> 
           <option value="Ingres">Ingres</option> 
           <option value="MySQL">MySQL</option> 
           <option value="Oracle">Oracle</option> 
           <option value="P6Spy">P6Spy</option> 
           <option value="PostgreSQL">PostgreSQL</option> 
           <option value="SQL Server">SQL Server</option> 
           <option value="Sybase">Sybase</option> 
         </select> 
        </tr> 
        <tr> 
         <td>JDBC URL(required)</td> 
        </tr> 
        <tr> 
         <td><input type="text" name="jdbcUrl" style="width: 550px;" id="jdbcUrl"></td> 
        </tr> 
        <tr> 
         <td>JDBC Driver Class Name(Required)</td> 
        </tr> 
        <tr> 
         <td><input type="text" name="text" style="width: 550px;"></td> 
        </tr> 
        <tr> 
         <td>username</td> 
        </tr> 
        <tr> 
         <td><input type="text" name="text" style="width: 550px;"></td> 
        </tr> 
        <tr> 
         <td>password</td> 
        </tr> 
        <tr> 
         <td><input type="password" name="text" style="width: 550px;"></td> 
        </tr> 
       </table> 
      </form> 
+0

變化的onclick = 「fillData()」 來的onChange = 「fillData(THIS.VALUE)」 – jeff

回答

0

用onchange替換onclick。這裏試試這個代碼:

<select name="Database Type" onchange="fillData()" id="sel_value"> 
     <option value="DB2">DB2</option> 
     <option value="Derby">Derby</option> 
     <option value="Hypersonic">Hypersonic</option> 
     <option value="Ingres">Ingres</option> 
     <option value="MySQL">MySQL</option> 
     <option value="Oracle">Oracle</option> 
     <option value="P6Spy">P6Spy</option> 
     <option value="PostgreSQL">PostgreSQL</option> 
     <option value="SQL Server">SQL Server</option> 
     <option value="Sybase">Sybase</option> 
</select> 

的Javascript:

function fillData(){ 
    alert($('#sel_value').val()); 
} 
相關問題