This module uses JavaScript technology to determine whether the search condition is empty and to change the data in the corresponding list based on the data selected by the user. When the user selects a search condition in the first list, the data in the second list changes and corresponds to the data in the first list, with the following key code:
Code location: Supporting Resources \mr\01\select.php
01 <script> 02 function fetch () { //determines whether the search keyword is empty 03 if (form1.key.value== "") { 04 alert (" Please enter a search keyword. "); 05 form1.value.select (); 06 return false; 07 } 08 return true; 09&NBSP;&NBSP} 10 </script> 11 <script language= " JavaScript "> 12 function press (opt) { //defines the press () method, controls the Select2 display value 13 //opt for the Drop-down list box to indicate the number of existing options 14 &nbsP;form1.select2.options[opt]=new option (ok= (form1.select2.options[opt))? 15 form1.select2.options[opt].innertext+string.fromcharcode (Event.keycode): 16 string.fromcharcode (Event.keycode), OK) 17 form1.select2.selectedindex=opt; 18&NBSP;&NBSP} 19 </script> 20 <script language= " JavaScript "> 21 function up (opt) { //defines the up () method to control Select2 value 22&NBSP;&NBSP;//OPT indicates the number of existing options 23 if (Form1.select2.options[opt]) { 24 if (event.keycode==8) { 25 var str=form1.select2.options[opt].innerText; 26&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&Nbsp; var len=str.length; 27 Form1.select2.options[opt].innertext=str.substring (0,len-1); 28 if ( form1.select2.options[opt].innertext== " ") Select2.remove (2); 29 } 30 if (event.keycode==32) { 31 form1.select2.options[opt].innertext+= " "; 32 } 33 } 34 } 35 </script>