JSP – Fetching Value of Radio Button
Radio button in JSP with same name return a single value to request object. Request.getParameter with radio field name will return a value of checked radio button.
Suppose we have three radio button and name of radioButton, if we select b value radio button, and submit this JSP page to getValue.jsp page. We will get value of request object is b. index.jsp
Fetching request value in this page of radio button
getValue.jsp
Suppose we have three radio button and name of radioButton, if we select b value radio button, and submit this JSP page to getValue.jsp page. We will get value of request object is b. index.jsp
<html> <head> <title>Radio Button</title> </head> <body> <form name="frm" action="getValue.jsp" method="post" > <input name="radioButton" type="radio" value="a" checked="checked"/> a <input name="radioButton" type="radio" value="b" /> b <input name="radioButton" type="radio" value="c" /> c <input name="goto" type="submit" value="Submit" /> </form> </body> </html>
getValue.jsp
<%@ page contentType="text/html; charset=iso-8859-1" language="java" %> <% String radioButton= request.getParameter("radioButton"); System.out.println("radioButton ::"+radioButton); out.println("Radio Button Value :"+radioButton); %>
沒有留言:
張貼留言