Recently, many people have asked questions about checkbox processing,
Now let's talk about my own practices on this issue!
Problem: (reference tnt_fireball (yi. Http://community.csdn.net/Expert/topic/3947/3947484.xml? Temp =. 2331659)
----------------------------------------------------------------
I want to create a course selection system. The appearance is as follows:
Term Course name course category credit score remarks retake course selection or not
2003-2004 (top) required statistical course 3 98 4 checkbox (0/1)
......................................... Checkbox (0/1)
... Checkbox (0/1)
... Checkbox (0/1)
...............
Because the course name is called from a schedule table in the database, the number of courses is small based on the number of tables, which is unknown at the beginning, therefore, the quantity and name definitions of the checkbox value are dynamic. Therefore, the checkbox value cannot be set at the beginning with "checkbox value = 1, 2, 4". How should we set it? Depressed, I cannot find anything ~
Then I want to record the course information of the select course database SC table, in the form:
Student ID ---- course number: one table, two attributes, and two attributes as the primary key.
Can you provide some ideas and examples for recording the information to the database based on the checkbox selection information?
I am not sure about JSP. I am already studying hard. I am here asking for advice. Everybody!
After reorganizing the problem: (reference tnt_fireball (yi. Http://community.csdn.net/Expert/topic/3947/3947484.xml? Temp =. 2331659)
--------------------------------------------------
The above looks changed. I want to rewrite it now because this system will not be used for the first question. Thank you ~
I want to create a course selection system. The appearance is as follows:
Term Course name course category credit score course selection or not
2003-2004 (top) required statistical course 3 98 4 checkbox (0/1)
.................................. Checkbox (0/1)
... Checkbox (0/1)
... Checkbox (0/1)
...............
Because the course name is called from a schedule table in the database, the number of courses is small based on the number of tables, which is unknown at the beginning, therefore, the quantity and name definitions of the checkbox value are dynamic. Therefore, the checkbox value cannot be set at the beginning with "checkbox value = 1, 2, 4". How should we set it? Depressed, I cannot find anything ~
Then I want to record the course information of the select course database SC table, in the form:
Student ID ---- course number: one table, two attributes, and two attributes as the primary key.
Can you provide some ideas and examples for recording the information to the database based on the checkbox selection information?
I am not sure about JSP. I am already studying hard. I am here asking for advice. Everybody!
Continue: (reference tnt_fireball (yi. Http://community.csdn.net/Expert/topic/3947/3947484.xml? Temp =. 2331659)
---------------------------------
Is it necessary to read only five records from the schedule table at a time, and then let the user select the course to submit, "one student number corresponds to one course number" is recorded in the database, read the next five displays of schedule. What are the user submissions ??
Otherwise, if you read all the content of schedule at a time, it will be:
Course 1 ...... checkbox (value = "1 ")
.....................
Course 6 ...... checkbox (value = "1 ")
So how can we differentiate the databases selected for different courses?
Can you explain it ?? I have no clue.
The following are my answers to this question:
------------------------------------------------------------
First, these checkboxes must have the same property, and then use value to differentiate them,
<HTML: checkbox property = "name" value = "Zhang San" Checked = "checked"> Zhang San <HTML: checkbox property = "name" value = "" Checked = "checked"> Li Si <HTML: checkbox property = "name" value = "">
There are three options. Only Michael and James are selected.
In your application, you can define an array,
String [] names = request. getparametervalues ("name ");
At this time, names automatically takes only the selected items,
Int sum = names. length; // here I is equal to 2
Then we can use the for loop to process the submitted information!
For (INT I = 0; I <sum; I ++ ){
Out. println (Names [I]. Value); // actual business
}
----------------------------------------------------
This problem is solved in this way!
Learn together!