SoFunction
Updated on 2025-02-28

Detailed explanation of the usage of checkbox in jsp

String[] picked = ("open");
  if (picked != null) {
   for (int i = 0;i < ; i++) {
  // ("11"+picked[i]);
   ( picked[i]); 
   } 
  }

Today I used checkbox with panic and always thought it was quite mysterious, but when you decided to calm down and get it done, I realized that things were far less difficult than I imagined O(∩_∩)O~

*****************************************************************************************************

Theories found online:

(Get the value in checkbox)

String[] picked = ("colname");
String[] a=new String[20];
 if (picked != null) {
  for (int i = 0;i < ; i++) {
   (" "+picked[i]);
 } else {
    ("none");
 }

How to achieve the selection of all jsp page checkbox.

Use javascript.

&lt;html&gt; 
&lt;body&gt; 
&lt;script&gt; 
function kk(){ 
var handleEl = ("kkHandler"); 
var els = ("kk"); 
for(i=0;i&lt;;i++){ 
els[i].checked = ; 
} 
 
} 
&lt;/script&gt; 
&lt;input type=checkbox onclick="kk()" name="kkHandler"&gt;Select all&lt;br&gt; 
&lt;input type=checkbox name="kk"&gt; 
&lt;input type=checkbox name="kk"&gt; 
&lt;/body&gt; 
&lt;/html&gt;

2:

<form name="form" ID="Form1"> 
<input type="checkbox" name="id" value="" ID="Checkbox1">1 
<input type="checkbox" name="id" value="" ID="Checkbox2">2 
<input type="checkbox" name="chose" value="" onclick="selectAll()" ID="Checkbox5">allselect 
</form> 
<script> 
function selectAll() 
{ 
if(!){ 
 if(){ 
  =true; 
 } 
 else{ 
  =false; 
 } 
} 
else{ 
 for(var i=0;i<;i++){ 
  if(){ 
  [i].checked=true; 
  } 
  else{ 
  [i].checked=false; 
  } 
 } 
}    
} 
</script>

******************************************************************************************************

My code

jsp page code:

&lt;script LANGUAGE = "javaScript"&gt;
&lt;!--
 function selectAll() 
 { 
 if(!){ 
  if(){ 
   =true; 
  } 
  else{ 
   =false; 
  } 
 } 
 else{ 
  for(var i=0;i&lt;;i++){ 
   if(){ 
   [i].checked=true; 
   } 
   else{ 
   [i].checked=false; 
   } 
  } 
 }    
}
--&gt;
&lt;/script&gt;

&lt;logic:present name="Infor"&gt;
 &lt;logic:iterate  name="Infor"&gt;
 &lt;tr bgcolor = '#E7F1FE'&gt;
 &lt;td width="5%"&gt;
 &lt;logic:equal value="Not activated" name="show" property="status"&gt;
  &lt;input type="checkbox" name="open" value="&lt;bean:write name="show" property="legalPersonCode" /&gt;"&gt;
 &lt;/logic:equal&gt;

How to write in action:

String[] picked = ("open");
     if (picked != null) {
         for (int i = 0;i < ; i++) {
       //   ("11"+picked[i]);
          ( picked[i]); 
         }
     }