Created
January 11, 2018 07:42
-
-
Save raunakhajela/e762e5d84ff11c80170d575e619a2c02 to your computer and use it in GitHub Desktop.
JSP: Forms - Checkboxes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<form action="student-checkbox-response.jsp"> | |
First name: <input type="text" name="fname" /> | |
<br/><br/> | |
Last name: <input type="text" name="lname" /> | |
<br/><br/> | |
<input type="checkbox" name="flang" value="java"/> Java | |
<input type="checkbox" name="flang" value="php"/> PHP | |
<input type="checkbox" name="flang" value="c"/> C | |
<input type="checkbox" name="flang" value="cpp"/> C++ | |
<br/><br/> | |
<input type="submit" value="Submit" /> | |
</form> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
The student is confirmed: ${param.fname} ${param.lname} | |
<br/><br/> | |
<!-- display list of "fav lang" --> | |
<ul> | |
<% | |
String[] langs = request.getParameterValues("flang"); | |
for(String tempLang: langs){ | |
out.println("<li>" + tempLang + "</li>"); | |
} | |
%> | |
</ul> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment