urema
urema

Reputation: 731

HTML JSP code creation question

I have a submit button, created from - basically when this is clicked I want a groupbox to appear below where the submit button is....any suggestions?

I've tried to get the request given of from this click however it doesn't help me. I thought the logic would be similar to this:

<form>
   <input type="checkbox" name="group" value="Yes" />Yes
   <input type="checkbox" name="group" value="No" /> No
   <input type="submit" value="submit" />
</form>
<%
   String[] select = request.getParameterValues("group");
  /* Add code creation here */
%>

Any suggestions or examples you can think of?

Thanks greatly, U.

Upvotes: 1

Views: 845

Answers (1)

BalusC
BalusC

Reputation: 1108537

First replace the checkboxes by radio buttons. Right now it's possible to check both Yes and No. This makes no sense.

<form>
   <input type="radio" name="group" value="Yes" /> Yes
   <input type="radio" name="group" value="No" /> No
   <input type="submit" value="submit" />
</form>

Then, use JSTL <c:if> tag to conditionally display content depending on parameters and/or other scoped variables in EL.

<c:if test="${param.group == 'Yes'}">
    <p>Write here HTML code which you'd like to show when 'Yes' is chosen.</p>
</c:if>
<c:if test="${param.group == 'No'}">
    <p>Write here HTML code which you'd like to show when 'No' is chosen.</p>
</c:if>

Upvotes: 2

Related Questions