Default options for php select, radio, and checkbox

Source: Internet
Author: User

This is the default Implementation Method to extend the select of yibing.
Copy codeThe Code is as follows:
<Select name = "wuyeleixing" size = "1">
<Option <? Php if ($ myrow [wuyeleixing] = 1) echo ("selected");?> Value = "1"> residential </option>
<Option <? Php if ($ myrow [wuyeleixing] = 2) echo ("selected");?> Value = "2"> Office </option>
<Option <? Php if ($ myrow [wuyeleixing] = 3) echo ("selected");?> Value = "3"> business Room </option>
<Option <? Php if ($ myrow [wuyeleixing] = 4) echo ("selected");?> Value = "4"> plant </option>
<Option <? Php if ($ myrow [wuyeleixing] = 5) echo ("selected");?> Value = "5"> repository </option>
<Option <? Php if ($ myrow [wuyeleixing] = 6) echo ("selected");?> Value = "6"> plot </option>
<Option <? Php if ($ myrow [wuyeleixing] = 7) echo ("selected");?> Value = "7"> comprehensive building </option>
<Option <? Php if ($ myrow [wuyeleixing] = 8) echo ("selected");?> Value = "8"> farm </option>

<Option <? Php if ($ myrow [wuyeleixing] = 9) echo ("selected");?> Value = "9"> business and residential buildings </option>
<Option <? Php if ($ myrow [wuyeleixing] = 10) echo ("selected");?> Value = "10"> Hotel and Restaurant </option>
<Option <? Php if ($ myrow [wuyeleixing] = 11) echo ("selected");?> Value = "11"> school buildings </option>

</Select>

Default Implementation of radio single queue
Copy codeThe Code is as follows:
<Input type = "radio" name = "dishu" value = "3" <? Php if ($ myrow [dishu] = 3) echo ("checked") ;?>> Blank
<Input type = "radio" name = "dishu" value = "1" <? Php if ($ myrow [dishu] = 1) echo ("checked") ;?>> Transfer
<Input type = "radio" name = "dishu" value = "2" <? Php if ($ myrow [dishu] = 2) echo ("checked") ;?>> Transfer
<Input type = "radio" name = "dishu" value = "4" <? Php if ($ myrow [dishu] = 4) echo ("checked") ;?>> Group

Default selection Implementation of the checkbox check box
Copy codeThe Code is as follows:
<Input name = "fujia_jiaju" type = "checkbox" value = "jiaju" <? Php if ($ myrow [fujia_jiaju]) echo ("checked") ;?>> </Font> </strong> </td>
<Td width = "108" height = "1"> <strong> <font color = "#008080" face = "_ GB2312"> <input
Name = "fujia_chuju" type = "checkbox" value = "chuju" <? Php if ($ myrow [fujia_chuju]) echo ("checked") ;?>> </Font> </strong> kitchen utensils </td>
<Td width = "96" height = "1"> <strong> <font color = "#008080" face = "_ GB2312"> <input
Name = "fujia_woju" type = "checkbox" value = "woju" <? Php if ($ myrow [fujia_woju]) echo ("checked") ;?>> </Font> </strong> bedding </td>
<Td width = "99" height = "1"> <strong> <font color = "#008080" face = "_ GB2312"> <input
Name = "fujia_ TV" type = "checkbox" value = "TV" <? Php if ($ myrow [fujia_ TV]) echo ("checked") ;?>> </Font> </strong> TV set

These form fields are suitable for modifying some database records and keeping the original records the same as when adding them!

Select is selected by default. select obtains the selected items.

Well, I have to admit that it is sometimes difficult to understand just a few lines of code for my JS, for example, it took me more than half an hour to solve the default Selection Problem of the front-end select statement today. The Code finally found solves the problem that it is quite simple to obtain the selected items by the select statement ,, the selection of select in html uses this JS to solve the problem very effectively. I think it is worth keeping it for me to share with my friends. The Code is as follows:

Copy codeThe Code is as follows:
<Form name = "FORM" method = "post" action = "" enctype = "multipart/form-data">
<Select name = 'aaa' id = 'bbb'>
<Option value = ''> existing Category </option> <option value = 'income'> Inner Mongolia </option>
<Option value = 'xinjiang '> Xinjiang </option> <option value = 'yunnan'> Yunnan </option>
<Option value = 'tibet '> Tibet </option> <option value = 'gansu'> Gansu </option>
<Option value = 'ningxia '> Ningxia </option> <option value = 'qinghai'> Qinghai </option>
<Option value = 'sichuan '> Sichuan </option> <option value = 'guangxi'> Guangxi </option>
<Option value = 'guizhou '> Guizhou </option> <option value = 'hainan'> Hainan </option>
<Option value = 'guangdong '> Guangdong </option> <option value = 'hunan'> Hunan </option>
<Option value = 'hubei '> Hubei </option> <option value = 'fujian'> Fujian </option>
<Option value = 'jiangxi '> Jiangxi </option> <option value = 'zhejiang'> Zhejiang </option>
<Option value = 'anhui '> Anhui </option> <option value = 'jiangsu'> Jiangsu </option>
<Option value = 'henan '> Henan </option> <option value = 'shaanxi'> Shaanxi </option>
<Option value = 'shandong '> Shandong </option> <option value = 'hebei'> Hebei </option>
<Option value = 'shanxi '> Shanxi </option> <option value = 'heilongjiang'> Heilongjiang </option>
<Option value = 'jilin'> Jilin </option> <option value = 'liaoning '> Liaoning </option>
</Select>
</Form>
<Script type = "text/java script">
<! --
Document. FORM. bbb. value = "Yunnan"; // FORM is the FORM name, atc_province is the select tag ID,
Select is selected by default in Yunnan
// -->
</Script>

Hope to help you

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.