Sh_Rashed
asked on
How to assign value to my checkbox if it is unchecked
Hi Experts,
I have table in a form and the table has many rows.
In each row I have check box its name is name = "issueItem1" .. it could be issueItem2 or 3 .. according to the row index.
When it is checked, the value = "issue<%= i %>" .. Where i is the row index , but if the check box is unchecked it gives me null value in my Servlet
here is my tag:
<td class = "td"><input type="checkbox" name="checkIssue<%=i%>" value="issue<%=i%>"></td>
so how I can assign value to my checkbox if it is unchecked?
any idea ? .. =)
I have table in a form and the table has many rows.
In each row I have check box its name is name = "issueItem1" .. it could be issueItem2 or 3 .. according to the row index.
When it is checked, the value = "issue<%= i %>" .. Where i is the row index , but if the check box is unchecked it gives me null value in my Servlet
here is my tag:
<td class = "td"><input type="checkbox" name="checkIssue<%=i%>" value="issue<%=i%>"></td>
so how I can assign value to my checkbox if it is unchecked?
any idea ? .. =)
you cannot do that. Try to use some other HTML control (two radio buttons, a select box).
ASKER
I am using jsp and servlet .. I need to send the form to the Servlet .. BUT if the check box is unchecked , it sends null value
I need the value of checkbox " When it is checked" to be YES else NO..
I need the value of checkbox " When it is checked" to be YES else NO..
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If you insist (but you really should change the logic of the jsp):
<%
String[] checks = new String[maxCheckboxes];
String checkVal = "";
for (int i=0;i<maxCheckboxes;i++) {
checkVal=request.getParame ter("check Issue"+i);
checks[i] = (checkVal==null || "".equals(checkVal))?"NO": "YES";
}
%>
<%
String[] checks = new String[maxCheckboxes];
String checkVal = "";
for (int i=0;i<maxCheckboxes;i++) {
checkVal=request.getParame
checks[i] = (checkVal==null || "".equals(checkVal))?"NO":
}
%>
ASKER
OK I got it .. I will change it to radio buttons ..
Thanks = )
Thanks = )
Can you "view source" on your browser, to see what the code looks like there?