A combination of JavaScript and select parts using _php basics

Source: Internet
Author: User
<?php

Combined use of JavaScript and select parts
In the process of writing a program, I want to implement the option that is selected when the Select Object
does not need to submit the button, but directly triggers the action, and after the action occurs
To keep the selected option on the page. After being described, finally passed
Using JavaScript and the onchange properties of the Select object and
Value value to achieve this function.
The code is as follows (file name is "test.php"):


Switch ($mon) {
Case ': Echo ' Please select your constellation: '; break;
Case ' 1 ': Echo ' your constellation is Aquarius ';
Case ' 2 ': Echo ' Your constellation is Pisces ';
Case ' 3 ': Echo ' Your constellation is Aries ';
Case ' 4 ': Echo ' Your constellation is Taurus ';
Case ' 5 ': Echo ' Your constellation is Gemini ';
Case ' 6 ': Echo ' Your constellation is cancer ';
Case ' 7 ': Echo ' Your constellation is Leo ';
Case ' 8 ': Echo ' your constellation is Virgo ';
Case ' 9 ': Echo ' your constellation is Libra ';
Case ' Ten ': Echo ' Your constellation is Scorpio ';
Case ' one ': Echo ' Your constellation is Sagittarius ';
Case ' a ': Echo ' Your constellation is the Scorpion ';
Default:break;
}
?>

<form name= "Form1" >
<select name= "Month_select"
Onchange= "javascript:location.href=
This.options[this.selectedindex].value ">
<option>--, please choose your constellation--</option>
<option value= "Test.php?mon=1"
<?php if ($mon = = "1") echo "selected";?>> Aquarius </option>
<option value= "test.php?mon=2"
<?php if ($mon = = "2") echo "selected";?>> pisces </option>
<option value= "Test.php?mon=3"
<?php if ($mon = = "3") echo "selected";?>> Aries </option>
<option value= "Test.php?mon=4"
<?php if ($mon = = "4") echo "selected";?>> taurus </option>
<option value= "Test.php?mon=5"
<?php if ($mon = = "5") echo "selected";?>> gemini </option>
<option value= "Test.php?mon=6"
<?php if ($mon = = "6") echo "selected";?>> cancer </option>
<option value= "Test.php?mon=7"
<?php if ($mon = = "7") echo "selected";?>> Leo </option>
<option value= "Test.php?mon=8"
<?php if ($mon = = "8") echo "selected";?>> virgo </option>
<option value= "Test.php?mon=9"
<?php if ($mon = = "9") echo "selected";?>> libra </option>
<option value= "test.php?mon=10"
<?php if ($mon = = "Ten") echo "selected";?>> Scorpio </option>
<option value= "test.php?mon=11"
<?php if ($mon = = "one") echo "selected";?>> sagittarius </option>
<option value= "Test.php?mon=12"
<?php if ($mon = = "") echo "selected";?>> scorpion </option>
</select>
</form>



"This article copyright belongs to the author and the Osso net jointly owns, if needs to reprint, please indicate the author and the origin"
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.