Hi ,
I have a JSP page where i have few checkboxes and i have disabled few of them usign javascript for certain conditions.
When i fetch the value from checkbox using request.getParameterValues("CheckBoxName"); , then do i get the values from disabled checkboxes too or disabled checkboxes are not considered by java when we fetch value?
Here is the code , checkbox with id s1 and s2 are dibaled using javascript

<form action="booking_cnf" method="post">
<!--  checkbox id is same as the value of SeatNo in the database -->
<!--  checkbox with id=1 and id=2 are disabled using javascript -->
<input type="checkbox" id="s1" name="seat" value="s1">
<input type="checkbox" id="s2" name="seat" value="s2">
<input type="checkbox" id="s3" name="seat" value="s3">
<input type="checkbox" id="s4" name="seat" value="s4">
<input type="hidden" name="doj" value="<%=doj%>">
<input type="hidden" name="BusNo" value="<%=BusNo%>">
<input type="submit" value="book">
</form>

Now the action class or model has the followind code

String BookSeats[] = request.getParameterValues("seat");
  if(BookSeats !=null){

      for(int i=0; i<BookSeats.length; i++){
          System.out.println(BookSeats[i]);
          //here i will insert the seats in database which are selected in checkboxes
      }
  }

Can i do this ?
I am confused , what happends with the disabled checkboxes?

Please Help

Disabled check boxes to not send their data on POST. Few alternatives:

1) Keep a hidden element with the check boxes with the same value.
2) Use javascript to enable all the check boxes on submit before the data is sent so they are included
3) Use CSS and JS to emulate a disabled box (prevent default event) without actually disabling them

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.