亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Home php教程 php手冊(cè) PHP中接收復(fù)選框信息的方法

PHP中接收復(fù)選框信息的方法

Jun 21, 2016 am 09:15 AM
form items lt

復(fù)選框

PHP接收多個(gè)同名復(fù)選框信息不像ASP那樣自動(dòng)轉(zhuǎn)換成為數(shù)組,這給使用帶來了一定不便。但是還是有解決辦法的,就是利用JavaScript做一下預(yù)處理。多個(gè)同名復(fù)選框在JavaScript中還是以數(shù)組的形式存在的,所以在表單提交之前可以利用JavaScript把復(fù)選框中的信息組合成一個(gè)字符數(shù)組賦值給表單中的隱藏元素,然后用PHP中的explode函數(shù)解析此數(shù)組,這樣就可以實(shí)現(xiàn)復(fù)選框信息的傳遞了。下面舉例說明。
假設(shè)有這樣一個(gè)表單:



1


2


3


4








這個(gè)表單有四個(gè)名字都是item的復(fù)選框,當(dāng)用戶單擊Submit按鈕的時(shí)候,Checker函數(shù)會(huì)被調(diào)用,并且如果Checker返回true表單就被提交,返回false表單就不會(huì)被提交。這里Checker函數(shù)就是我們要編寫的預(yù)處理函數(shù)。在HTML的header部分添加下面的JavaScript:



這樣就可以把所有選中的復(fù)選框的value組合成為一個(gè)字符串?dāng)?shù)組,在myphp.php使用這樣的語句:

$items = explode(" ", $HTTP_POST_VARS["items"]);

就可以把這些選項(xiàng)分離出來成為數(shù)組。需要注意的是選項(xiàng)中的value不能包含分割符(這里是空格)。



Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

PHP Tutorial
1488
72
php提交表單通過后,彈出的對(duì)話框怎樣在當(dāng)前頁彈出,該如何解決 php提交表單通過后,彈出的對(duì)話框怎樣在當(dāng)前頁彈出,該如何解決 Jun 13, 2016 am 10:23 AM

php提交表單通過后,彈出的對(duì)話框怎樣在當(dāng)前頁彈出php提交表單通過后,彈出的對(duì)話框怎樣在當(dāng)前頁彈出而不是在空白頁彈出?想實(shí)現(xiàn)這樣的效果:而不是空白頁彈出:------解決方案--------------------如果你的驗(yàn)證用PHP在后端,那么就用Ajax;僅供參考:HTML code

How to use items in python How to use items in python Nov 28, 2023 am 11:29 AM

In Python, the items() method is usually used on dictionary objects to return all key-value pairs of the dictionary. This is a member method of a dictionary, so you cannot use it directly on any object unless that object is a dictionary.

BinaryX is renamed FORM again, and the FOUR it gives to the community is about to soar? BinaryX is renamed FORM again, and the FOUR it gives to the community is about to soar? Mar 04, 2025 pm 12:00 PM

BinaryX's token name change: from BNX to FOUR, and then to FORM, the deep meaning behind strategic adjustments BinaryX recently changed the token symbol from $FOUR to $FORM, which has attracted widespread attention from the industry. This is not the first time BinaryX has changed its name, and its token symbol has undergone a transition from BNX to FOUR. This article will explore in-depth the strategic intentions behind this series of name change. 1. Token name change process and strategic considerations BinaryX initially launched the $BNX token based on the BNB chain in 2021 to support its Play-to-Earn (P2E) gaming ecosystem. In early 2024, in order to optimize the economic model, BinaryX divided $BNX and gradually expanded to GameF

請(qǐng)教怎么修改url某一參數(shù)的參數(shù)值呢?是要拆開了再拼回去嗎 請(qǐng)教怎么修改url某一參數(shù)的參數(shù)值呢?是要拆開了再拼回去嗎 Jun 13, 2016 am 10:24 AM

請(qǐng)問如何修改url某一參數(shù)的參數(shù)值呢?是要拆開了再拼回去嗎?那么請(qǐng)問如何修改url某一參數(shù)的參數(shù)值呢?是要拆開了再拼回去嗎?http://127.0.0.1/myo/newuser.php?mod=search&type=fastone比如現(xiàn)在我要修改mod=new要怎么做呢?------解決方案--------------------發(fā)送了請(qǐng)求

Microsoft is rolling out Windows 11 23H2 build to the release preview channel with Copilot Microsoft is rolling out Windows 11 23H2 build to the release preview channel with Copilot Sep 28, 2023 pm 07:17 PM

Everyone is looking forward to today's Windows 1123H2 release. In fact, Microsoft has just launched updates to the release preview, which is the closest channel before the official release stage. Known as Build 22631, Microsoft said they are rolling out the new rebranded chat app, phone link, and play together widgets that have been tested on other internal channels over the past few months. "This new update will have the same servicing branch and codebase as Windows 11 version 22H2 and will be cumulative with all newly announced features, including Copilot in Windows (preview)," Microsoft promises. Redmond officials further

Can there be multiple forms in html5? Can there be multiple forms in html5? Aug 01, 2022 pm 05:28 PM

There can be multiple forms in html5. The rules allow multiple form tags to be used in the same HTML page. However, in order to prevent the backend from not recognizing it when submitting, you need to add different IDs or classes to the form. The syntax is "<from action="url" id=" id value 1">Form element</from><from action="url" id="id value 2">Form element</from>.....".

What is the tag that defines the form in html5 What is the tag that defines the form in html5 Jul 26, 2022 pm 04:26 PM

The tag defining a form in HTML5 is "<form>". The form tag is used to create an HTML form (form field) for user input to collect and transfer user information. All content in the form will be submitted to the server; the syntax "<form action="Submit Address" method="Submit Method " name="form name">form control</form>". A form can contain one or more form elements, such as input, select, and textarea.

Comprehensively organize elements related to form forms! Comprehensively organize elements related to form forms! Aug 05, 2022 am 11:45 AM

This article gives you a detailed summary of the knowledge points related to form elements in HTML. I hope it will be helpful to you!

See all articles