search
HomeWeChat AppletMini Program DevelopmentWeChat applet uses checkbox to display multiple selection box function [source code attached]

This article mainly introduces the function of using checkbox to display multiple selection boxes in WeChat applet, involving related event binding and element traversal operation techniques, and comes with source code for readers to download and refer to. Friends in need can refer to it

The example in this article describes the WeChat applet's use of checkbox to display multiple selection boxes. Share it with everyone for your reference, the details are as follows:

1. Effect display

##2. Key code

① index.wxml

<checkbox-group bindchange="checkboxgroupBindchange">
 <checkbox value="checkbox1">checkbox1</checkbox>
 <checkbox value="checkbox2">checkbox2</checkbox>
 <checkbox value="checkbox3">checkbox3</checkbox>
</checkbox-group>
<view>提示:{{text}}</view>

② index.js

Page({
 data:{
  // text:"这是一个页面"
  text:&#39;&#39;
 },
 checkboxgroupBindchange:function(e){
  var temp1=e.detail.value
  var temp2=&#39;&#39;
  console.log(temp1)
  if(temp1.length!=0){
   for(var i=0,len=temp1.length;i<len;i++){
    temp2=temp2+temp1[i]+&#39;,&#39;
   }
   this.setData({
    text:&#39;您选择了:&#39;+temp2
   })
  }else{
   this.setData({
    text:&#39;&#39;
   })
  }
 }
})

3. Source code

For detailed usage instructions of the checkbox component, please refer to the official website:

https://mp.weixin.qq.com/debug/wxadoc/dev/component/checkbox.html

The above is the entire content of this article. I hope it will be useful for everyone’s learning. For help, please pay attention to the PHP Chinese website for more related content!

Related recommendations:

WeChat applet uses radio to display single option function [source code attached]

The above is the detailed content of WeChat applet uses checkbox to display multiple selection box function [source code attached]. For more information, please follow other related articles on the PHP Chinese website!

Statement
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

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.

Undress AI Tool

Undress AI Tool

Undress images for free

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

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Atom editor mac version download

Atom editor mac version download

The most popular open source editor