简体   繁体   中英

Radio Button Struts 1.3

I would like to create a radio button to select the values displayed on a jsp page. how can I use radio buttons to select values from this JSP page ?

<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. If the session logic present set the value of particular radio button as true. For iterating purpose also you can use logic:iterate tag. 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..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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