Combined Use of Javascript and select components

Source: Internet
Author: User

<? Php

// Use Javascript and select components in combination
// In the process of writing a program, after selecting the select object option,
// You do not need to submit a button, but directly trigger the action.
// To keep the selected options on the page. Finally
// Use the onchange attribute and
// Value to implement this function.
// The Code is as follows (the file name is "test. php "):


Switch ($ mon ){
Case: echo select your constellation:; break;
Case 1: echo your constellation is Aquarius; break;
Case 2: echo your constellation is Pisces; break;
Case 3: echo your constellation is Aries; break;
Case 4: echo your constellation is Taurus; break;
Case 5: echo your constellation is Gemini; break;
Case 6: echo your constellation is cancer; break;
Case 7: echo your constellation is Leo; break;
Case 8: echo your constellation is Virgo; break;
Case 9: echo your constellation is Tianping; break;
Case 10: echo your constellation is Scorpio; break;
Case 11: echo your constellation is Sagittarius; break;
Case 12: echo your constellation is Capricorn; break;
Default: break;
}
?>

<Form name = "form1">
<Select name = "month_select"
OnChange = "javascript: location. href =
This. options [this. selectedIndex]. value ">
<Option> -- Select 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" ;?>> Tianping seat </option>
<Option value = "test. php? Mon = 10"
<? Php if ($ mon = "10") echo "selected" ;?>> Scorpio </option>
<Option value = "test. php? Mon = 11"
<? Php if ($ mon = "11") echo "selected" ;?>> Sagittarius </option>
<Option value = "test. php? Mon = 12"
<? Php if ($ mon = "12") echo "selected" ;?>> Capricorn </option>
</Select>
</Form>



[This article is copyrighted by the author and osuo. If you need to reprint it, please indicate the author and its source]

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.