Home >Backend Development >PHP Tutorial >Combined use of javascript and select components_PHP tutorial
//Combined use of Javascript and select components
//In the process of writing the program, I want to realize that after the option is selected in the select object,
//No submit button is required , and trigger the action directly, and the selected option must be maintained in the
// page after the action occurs. After describing it, I finally realized this function by using Javascript and the onchange attribute and
//value of the select object.
//The code is as follows (the file name is "test.php"):
switch ($mon){
case '': echo 'Please select your zodiac sign:'; break;
case '1':echo 'Your zodiac sign is Aquarius';break;
case '2':echo 'Your zodiac sign is Pisces';break;
case '3':echo 'Your zodiac sign is Aries';break;
case '4':echo 'Your zodiac sign is Taurus';break;
case '5':echo 'Your zodiac sign is Gemini';break;
case '6':echo 'Your zodiac sign is Cancer';break;
case '7':echo 'Your zodiac sign is Leo';break;
case '8':echo 'Your zodiac sign is Virgo';break;
case '9':echo 'Your zodiac sign is Libra';break;
case '10':echo 'Your zodiac sign is Scorpio';break;
case ' 11':echo 'Your zodiac sign is Sagittarius';break;
case '12':echo 'Your zodiac sign is Capricorn';break;
default:break;
}
?>