if(a=1){
 b="checked";
}else{
 b="";
}<input type =ratio name=r value="0" <%=b%>>
<input type =ratio name=r value="1" <%=b%>>a是数据库中判断哪个被选中的字段,你自己决定

解决方案 »

  1.   

    错了~~~<input...得写到判断里去要根据你的情况来具体写
      

  2.   

    <input type =ratio name=r value="0"  onClick="ck(0)" >
    <input type =ratio name=r value="1"  onClick="ck(1)" >
    写个JAVASCRIPT函数
    function ck(i){
      if (i==0){
        //转到某个SERVLET或着通过URL转到某个JSP页面(在此操作数据库)
      } else if (i==0){    
        //转到某个SERVLET或着通过URL转到某个JSP页面(在此操作数据库)
      }
    }
      

  3.   

    一.连接数据库,获得两个单选框各个的值为多少.其中值为0的单选框为已选中状态.
       
    二.通过if else语句.
    <form name="form1" method="post" action="save.jsp">
    <%if 值为0 then 
      输出 <input name="dan" type="radio" value="0" checked>CCW 
      else
      输出 <input type="radio" name="dan" value="1">CCT
    </form>
    end if%>三.通过提交表单,dan的值重设数据库中的值,若这时选中的为值1,则数据库中的值为1.再次读数据库时,得到值为1,所以已选中的为CCT
      

  4.   

    submit.jsp
    连接数据库,取得su的值.
    <%
    out.println("<form name=form1 method=post action=1.jsp>");
    if(su==0){
    out.println("<input name=dan type=radio value=0 checked>"); 
    out.println("CCW ");
    out.print("<input type=radio name=dan value=1> ");
    out.println("CCT");}else{
    out.println("<input name=dan type=radio value=0>"); 
    out.println("CCW ");
    out.print("<input type=radio name=dan value=1 checked> ");
    out.println("CCT");}
    out.println("<input type=submit name=submit>");
    out.println("</form>");
    out.println("<br>");
    out.println("</body>");
    out.println("</html>");
    %>
    1.jsp
    连接数据库
    <%String show=request.getParameter("dan");%>
    将数据提交到数据库中