简体   繁体   English

单选按钮支柱1.3

[英]Radio Button Struts 1.3

I would like to create a radio button to select the values displayed on a jsp page. 我想创建一个单选按钮以选择在jsp页面上显示的值。 how can I use radio buttons to select values from this JSP page ? 如何使用单选按钮从此JSP页面中选择值?

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%! int i=0; %>

<h1 align="center">DOCUMENT INFORMATION CENTER</h1> 
<table border="12" align="center">

<tr><td>Employee ID</td><td>Document ID</td><td>Topic</td><td>Text</td><td>Files</td></tr>
<% int j=(Integer)session.getAttribute("i");
HttpSession session2=request.getSession();
for(i=0;i<j;i++)
{ out.println("<tr><td>"+session.getAttribute("eid"+i)+"</td><td>"+session2.getAttribute("id"+i)+"</td><td>"+session2.getAttribute("topic"+i)+"</td><td>"+session2.getAttribute("text"+i)+"</td><td>"+session2.getAttribute("files"+i)+"</td></tr>");
}

%>
</table>
</body>
</html>

You can use struts logic tags for this purpose. 您可以为此目的使用struts逻辑标记。 If the session logic present set the value of particular radio button as true. 如果存在会话逻辑,则将特定单选按钮的值设置为true。 For iterating purpose also you can use logic:iterate tag. 出于迭代目的,您还可以使用逻辑:iterate标签。 Following piece of code may help you. 遵循以下代码段可能会对您有所帮助。

<logic:present name="i" scope="session">
<logic:equal value="1" name="i" scope="session">
    <script>
        $('input[name=some_name][value=1]').prop("checked",true);
    </script>
</logic:equal>
</logic:present>

Let me know if this helps.. 让我知道这是否有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM