A detailed explanation of checkbox usage in JSP _jsp programming

Source: Internet
Author: User
string[] picked = Request.getparametervalues ("open");
  if (picked!= null) {for
   (int i = 0;i < Picked.length; i++) {
  //System.out.println ("one" +picked[i]);
   Udao.getcheckopen (Picked[i]); 
   } 
  

Today with the mood of fear with the next checkbox, has always thought quite mysterious things, but when you decide to calm down to get it done, only to find things far from imagining difficulties O (∩_∩) o~

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

From the Internet to find the theory:

(Gets the value in the checkbox)

string[] picked = Request.getparametervalues ("colname");
String[] A=new string[20];
 if (picked!= null) {for
  (int i = 0;i < Picked.length; i++) {
   out.println ("" +picked[i]);
 else {
   out.println ("none");
 }

How to implement a full selection of JSP page checkbox.

Use JavaScript.

 
 

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" 
checkbox "Type=" Name= "chose" " Onclick= "SelectAll ()" id= "Checkbox5" >allselect 
</form> 
<script> 
function SelectAll () 
{ 
if (!document.form.id.length) { 
 if (document.form.chose.checked) { 
  document.form.id.checked= true; 
 } 
 else{ 
  document.form.id.checked=false 
 } 
} 
else{for 
 (var i=0;i<document.form.id.length;i++) { 
  if (document.form.chose.checked) { 
  document.form.id[i].checked=true; 
  } 
  else{ 
  document.form.id[i].checked=false    
} 
}} </script>

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

My Code

JSP page code:

<script LANGUAGE = "JavaScript" >
<!--
 function SelectAll () 
 { 
 if (!) Document.form.open.length) { 
  if (document.form.chose.checked) { 
   document.form.open.checked=true; 
  } 
  else{ 
   document.form.open.checked=false 
  } 
 } 
 else{for 
  (var i=0;i<document.form.open.length;i++) { 
   if (document.form.chose.checked) { 
   document.form.open[i].checked=true; 
   } 
   else{ 
   document.form.open[i].checked=false    
}
}} -->
</script>

<logic:present name= "infor" >
 <logic:iterate id= "show" Name= "Infor" >
 <tr bgcolor = ' #E7F1FE ' >
 <td width= "5%" >
 <logic:equal value= "not opened" name= "show" property= "status" >
  <input type= "checkbox" name= "Open" value= "<bean:write name=" show "property=" Legalpersoncode "/>" >
 </logic:equal>

Action inside the wording:

String[] picked = Request.getparametervalues ("open");
     if (picked!= null) {
         for (int i = 0;i < Picked.length; i++) {
      //   System.out.println ("one" +picked[i]);
           Udao.getcheckopen (Picked[i]); 
         }
    }

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.