遇到這樣一個問題
頁面中有幾個數據項用struts的<html:select>標簽展示,今天提出新的需求,要不允許修改這幾個<html:select>,那就禁用咯,這樣問題發現了,這個頁面是來自action,給<html:select>對應actionForm中的屬性付了值,頁面顯示<html:select>自然就選中被賦值的選項,但是提交表單的時候,數據保存的確總是<html:select>列表中的第一個值,如果去掉禁用,就正常了。暈。
試著在onload中用js禁用也不行
在網上搜到一個這樣的寫法,實現readonly了
<select onbeforeactivate="return false" onfocus="this.blur()" onmouseover="this.setCapture()" onmouseout="this.releaseCapture()">
<option>1</option>
</select>
不過要用到<html:select>中要把
onbeforeactivate="return false" 去掉,<html:select>不認識這個屬性,不過效果還是實現了。