Getting all selected checkboxes values using ajax and jsp/servlets?

后端 未结 1 1249
一整个雨季
一整个雨季 2021-01-24 03:04

I\'m developing a jsp/serlvet application. I have a page with a list of inputs as checkboxes . I want to send values of selected buttons to a servlet using ajax/jquery. In the s

相关标签:
1条回答
  • 2021-01-24 03:44
    1. They are sent using their name, repeated:

      servlet?do=deleteSelected&checkboxGroup=value1&checkboxGroup=value2
      

      You can see that with the following simple html (after you press the submit button, take a look at the address bar):

      <form method="get">
      <input type="checkbox" name="checkboxGroup" value="1" />
      <input type="checkbox" name="checkboxGroup" value="2" />
      <input type="checkbox" name="checkboxGroup" value="3" />
      <input type="submit" />
      </form>
      
    2. You obtain them using:

      String[] values = request.getParameterValues("checkboxGroup");
      
    0 讨论(0)
提交回复
热议问题