select標籤和input標籤合體
阿新 • • 發佈:2018-12-21
html:主要是要style要設定好,兩者看起來吻合
<td> <select align="left" id="type" style="width:300px;height:30px;" onchange="voluation()" > <%--<option value=""></option>--%> <c:forEach items="${requestScope.selectsqlabout}" var="themtype"> <c:if test="${themtype.sqltype!=null}"> <option selected="selected" value="${themtype.sqltype}">${themtype.sqltype}</option> </c:if> </c:forEach> <input type="text" id="sqltype" name="sqltype" value="${Sqltypess}" style="width: 282px;height: 29px;margin-left: -303px;"> </select> </td>
js:把選擇的值賦給input
function voluation(){ var selectValue = $(’#type’).val(); console.log(selectValue); $("#sqltype").val(selectValue); }