How to Compare a radio Selection in JSP. I want to make radio selection unselectable depending on the another radio selection.
Below is Jsp Code. The JSP Page is linked with some Java files where the retrieve and display is done from the database.

Below is the link which contains the image for better understanding of the issue.

Click Here

<html>
<script>
function chk()
{
var txt=document.getElementById("amount");
txt.value=  parseFloat(txt.value).toFixed(2);

alert (i.value);
}
</script>
<center>
<table border=0 cellpadding=2 cellspacing=0 width=500 summary="layout">
   <tr>
      <td valign="top" colspan="4">   
        <c:url var="url" value="/transferAck" />
      <form name="transfer" method="post" action="${url}" >
        <table border=1 cellpadding=2 cellspacing=0 summary="layout">
        <tr>
          <td><b><fmt:message key="AccountName"/></b></td>
          <td><b><fmt:message key="AccountId"/></b></td>
          <td><b><fmt:message key="AccountBalance"/></b></td>
          <td><b><fmt:message key="AccountFrom"/></b></td>
          <td><b><fmt:message key="AccountTo"/></b></td>
        </tr>
        <c:forEach items="${accounts}" var="ad">
          <tr>
            <td>${ad.description}</td>
            <td>${ad.accountId}</td>
            <td align="right"><fmt:formatNumber value="${ad.balance}" type="currency" /></td>
            <td><input type="radio" name="fromAccountId" value="${ad.accountId}"></td>
            <td><input type="radio" name="toAccountId" value="${ad.accountId}"></td>
          </tr>
        </c:forEach>
        </table>
      </td>
    </tr>



</script>

    <tr>
        <td><b><fmt:message key="TransferAmount"/></b></td>
        <td><input id="amount" type="text" size="15" name="transferAmount" onblur="chk()"></td>
        <td><input type="submit" value="<fmt:message key='Submit'/>"></td>
        <td><input type="reset" value="<fmt:message key='Clear'/>"></td>
    </form>
    </tr>

</table>
</center>
</html>
Member Avatar for LastMitch

How to Compare a radio Selection in JSP. I want to make radio selection unselectable depending on the another radio selection. Below is Jsp Code. The JSP Page is linked with some Java files where the retrieve and display is done from the database.

@MariannJ

I don't click on links, so you better explain clearly what you are having problems.

<input type="radio" name="fromAccountId" value="${ad.accountId}" <c:if test="${shouldBeChecked==true}"><%= "checked" %></c:if> />

where "shouldBeChecked" is the attribute that you send from the controller to the view

why exactly do you not group your radiobuttons? are they both supposed to be checkable at simultaneously? then maybe checkboxes are more suited.
users might assume that only one of your radiobuttons might be selected.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.