this is my code where i am putting values to the checkbox value by getstring

i getting problem when displaying the value of checkbox value which displays"Undefined"
please give some solution.
where i want to get the value of my checkbox which i have been selected

Dani AI

Generated

reported that selected checkbox values are showing as "Undefined". asked for the code and noted the original snippet was removed, so here are the common causes and minimal, practical examples to compare against the deleted code.

Typical causes

  • The checkbox parameter never reaches the server (unchecked boxes are not sent).
  • A name mismatch between the input and the request lookup.
  • Client-side JavaScript is reading a non-existent element (JavaScript shows "undefined").
  • Multiple checkboxes with the same name require getParameterValues, not getParameter.

Minimal HTML + JSP example

<form method="post" action="process.jsp">
  <input type="checkbox" name="choice" value="A">A
  <input type="checkbox" name="choice" value="B">B
  <input type="submit" value="Send">
</form>

In process.jsp (server-side)

String[] choices = request.getParameterValues("choice");
if (choices != null) {
  for (String c : choices) out.println(c + "<br>");
} else {
  out.println("No checkbox selected");
}

Client-side check (common source of "undefined")

const vals = Array.from(document.querySelectorAll('input[name="choice"]:checked'))
                  .map(el => el.value);
console.log(vals); // [] when none selected

If JavaScript prints the literal "Undefined", inspect any scripts that read .value from an element that may not exist or use an undeclared variable.

Quick troubleshooting checklist

  • Confirm each checkbox has a name and (if needed) a value attribute (no value defaults to "on").
  • Use request.getParameterValues("name") for groups; request.getParameter("name") for single checkboxes.
  • Verify the form method and the servlet/JSP request handling match (POST vs GET).
  • Disabled inputs are not submitted. Check the browser Network tab to see the actual payload.
  • Look for client-side code that may overwrite or print an undefined variable.

Because the original code was deleted, the examples above cover the usual causes; compare them against the removed snippet to find the mismatch.

Recommended Answers

All 2 Replies

post code

looks like Dani deleted "zuh koduz" :)

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.