select中實現(xiàn)readonly的方法
今天在做一個頁面的時候,遇到一個問題,添加和更新使用同一個頁面,當添加的時候,select可以正常使用,如果是更新,那么要求select的值是指定的,并且不可使用,保存時,該控件的值可以正常保存,大家知道select控件沒有readonly屬性,但是我們還需要用到該功能,該如何實現(xiàn)呢?上網(wǎng)搜索了一下,發(fā)現(xiàn)一種不錯的方法,貢獻給大家,代碼如下:
<select name="projInveSour.phaseType" <c:if test='${method eq "update"}'> onbeforeactivate="return false" onfocus="this.blur()" onmouseover="this.setCapture()" onmouseout="this.releaseCapture()" </c:if>>
<option value="">全部</option>
<option value="立項" <c:if test='${projInveSourForm.projInveSour.phaseType eq "立項"}'>selected</c:if>>立項</option>
<option value="初設(shè)" <c:if test='${projInveSourForm.projInveSour.phaseType eq "初設(shè)"}'>selected</c:if>>初設(shè)</option>
</select>
紅色部分為關(guān)鍵代碼,大家參考一下,呵呵