function targch(p){
document.location.href="parrangehead.jsp?st=<%=st%>&trgno="+p;
parent.custbody.document.location.href="parrangebottom.jsp?trgno="+p;
}
<!-- <select name="targetlg" onchange='targch(this.value)'>
<%
Iterator it=ptk.iterator();
while(it.hasNext()){
trgnum++;
Projectask pjtk=(Projectask)it.next();
int targetlng=pjtk.gettargetlg();
String targetlngname=pjtk.gettargetlgname();
if(targetlng==Integer.parseInt(targ)){
out.println("<option value="+targetlng+" 'checked'>"+targetlngname+"</option>");
theFirstIdno=pjtk.getIdno();
setauto=ProjectManager.getInstance().hasAutoArrange(theFirstIdno);
}
else out.println("<option value="+targetlng+">"+targetlngname+"</option>");
}
%>
<script language="javascript">
obj = document.FormName.targetlg;
for(i=0;i<obj.length;i++){
if(obj.options[i].value=='<%=targ%>'){
obj.options[i].selected = true;
break;
}
}
</script>
</select>
-->
本文介绍了一个使用JavaScript和JSP实现的选项菜单动态更新案例。通过监听选择框的改变事件并根据所选值更新页面位置,展示了如何在Web应用中实现交互式的功能。此外,还介绍了如何通过迭代集合来填充下拉菜单,并保持当前选定项。

被折叠的 条评论
为什么被折叠?



