当前位置:编程学习 > JSP >>

jsp单选按钮状态传递问题

我有两个jsp页面,分别为a.jsp和b.jsp,而且这两个页面有一组相同的单选按钮,当我在a.jsp页面选中一个单选按钮并提交至b.jsp时,如何让b.jsp中的相应按钮也被选中?没分了,高手们见谅哈、、、
答案:很容易的..
先是a.jsp页面中的radio代码
<input type="radio"  name="a" value="0"  checked="true">------这里是默认选中,随便你自己设
<input type="radio"  name="a" value="1">
  在b.jsp页面中写这么一段代码
 <%
       String Radio=request.getParameter("a");
%>
<input type="radio"  name="a" value="0" if(Radio.equals("0")){out.println("checked=true")}>
<input type="radio"  name="a" value="1"if(Radio.equals("1")){out.println("checked=true")}>
这个if判断里面的代码可能有一些应该要加<%%>  因为我很久没弄了 又是在家里 台式机上我没安装MyEclipse  怕弄错...所以我就没加<%%>
   希望你能明白
其他:b.jsp
<script>
  alert(opener.window.document.getElementById("_radio").value );
  alert(opener.window.document.getElementById("_radio").checked );
  如果被选中就加句 document.getElementById("_radio").checked  ;
</script> 

上一个:如何将html文件转化成jsp文件?
下一个:php/jsp/aspx/asp/cfm/ruby/cgi/python/perl/html/htm 那种编程语言最常用?

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,