<BODY>
<select name= "gpr" id= "gpr" onchange= "change(this.value)" >
<option value= "1" >班級1
<option value= "2" >班級2
<option value= "3" >班級3
<option value= "4" >班級4
<option value= "5" >班級5
</select>
<SCRIPT LANGUAGE= "JavaScript" >
<!--
var x = '3' ; //這個是上次選中的值,你應(yīng)該放到request中返回的時候可以取到
var sel = document.getElementById( 'gpr' );
for ( var i=0;i<sel.options.length;i++){
if (sel.options[i].value==x){
sel.options[i].selected= true ; break ;
}
}
function change(pm){
//submit form
}
//-->
</SCRIPT>
</BODY>
// 設(shè)置頁面Select對象的選中狀態(tài)
function getSelectState(selectId, optionValue){
var sel = document.getElementById(selectId);
for ( var i=0;i<sel.length;i++) {
if (sel.options[i].value == optionValue) {
sel.selectedIndex = i;
break ;
}
}
}
// 使用
$(document).ready( function (){
// 要設(shè)置的Select的id
getSelectState( "id" , "${param.id}" );
});
|