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