This is a registration form, requiring users to select "Professional staff" and "qualitative staff, display the corresponding forms of "visitors are available" and "industries that are easy to access" respectively. When the two boxes are unselected, they are also hidden.
This is a registration form, requiring users to select "Professional staff" and "qualitative staff, display the corresponding forms of "visitors are available" and "industries that are easy to access" respectively. When the two boxes are unselected, they are also hidden.
Html section
The Code is as follows:
Register for a part-time position (required)
Press Ctrl to select multiple
Household Administrator Street visitor Street access blocker Telephone staff Mystery customer Professional staff Enterprise visitors Qualitative Liaison Officer Host Quality Controller Data Recorder
The type of the respondent can be provided.
Industries that are easy to access
Javascript Section
Option cannot define the event (I did not try it out), so the event must be defined on select. The onchange event is used here, And the onchange event is triggered when the object changes. Here, the onchange event is much more reasonable than the onclick event, and the effect is better.
When debugging this script, I first used selectedIndex. The experiment found that selectedIndex can only capture the first selected option when multiple options are selected. I checked the reference books and found that I had taken a detour.
The Code is as follows:
Var oListBox = document. getElementById ("kc_selectjob ");
OListBox. onchange = function showEasyVisitBox (){
Var oEasyvisitBox = document. getElementById ("easyvisitBox ");
Var oSupportvisitBox = document. getElementById ("supportvisitBox ");
If (oListBox. options [5]. selected)
{
OEasyvisitBox. style. display = "block ";
}
Else {
OEasyvisitBox. style. display = "none ";
}
If (oListBox. options [7]. selected)
{
Osuppvisvisitbox. style. display = "block ";
}
Else {
Osuppvisvisitbox. style. display = "none ";
}
}