


Sample code sharing for dynamically displaying the progress bar of the review process status using JavaScript (picture)
For things with many processes, we hope to display them correspondingly with process bars according to different stages, which is very intuitive and brings an excellent user experience to users. The editor will share with you below JavaScriptImplementationAuditProcessDynamic display of statusProgress bar function, friends who need it can refer to it
For things with many processes, We hope to use the process bar to display accordingly according to different stages, as shown below:
The html code corresponding to the above functions is as follows:
<p class="col-md-12 col-lg-3"> <p class="panel panel-default"> <p class="tit06"> <h3>漏洞处理状态</h3> </p> <p class="status"> <ul> <li name="tab_step1_pub" class="top active"> <p class="info" id="tab_step1"> <h4> <p class="heading"></p> 待审阅</h4> <p class="text" >漏洞已提交,等待厂商审阅</p> </p> </li> <li name="tab_step2_pub" > <p class="info" id="tab_step2"> <h4> <p class="heading"></p> 待确认</h4> <p class="text" >漏洞已开始审阅,等待厂商确认</p> </p> </li> <li name="tab_step3_pub"> <p class="info" id="tab_step3"> <h4> <p class="heading"></p> 待修复</h4> <p class="text" >漏洞已被确认,等待厂商修复</p> </p> </li> <li name="tab_step4_pub"> <p class="info" id="tab_step4"> <h4> <p class="heading"></p> 已关闭</h4> <p class="text" >漏洞修复完毕,厂商关闭漏洞</p> </p> </li> <li name="tab_step5_pub" > <p class="info" id="tab_step5"> <h4> <p class="heading"></p> 已公开</h4> <p class="text" >厂商同意公开此漏洞</p> </p> </li> </ul> </p> </p> </p>
The method used here is based on the processing status, here is $status
, correspondingly add a style class to the corresponding <li> tag class="active"
, and what is implemented in the style class active is to replace the background image at the corresponding position, that is, replace the original gray process lines with green process lines. That is, you need to set the corresponding css after and before replacement. The corresponding css here are as follows (part of \assets\default\threatrules\style.css):
.status ul { padding: 15px; } .status ul li { overflow: hidden; background: url("../threatrules/steps-line.jpg") repeat-y -3px 0px; padding: 26px 0 0px; } .status .active { background: url("../threatrules/steps-line-over.jpg") repeat-y -3px 0px; } .status .end { background: url("../threatrules/steps-line-over.jpg") repeat-y -3px 0px; } .status .end .heading { background: url("../threatrules/steps-over.jpg") no-repeat 0px 0px; } .status .bottom { background: url("../threatrules/steps-line.jpg") repeat-y -3px 0px; } .status .skip { background: url("../threatrules/steps-line-skip.jpg") repeat-y -3px 0px; } .status .skip .heading { background: url("../threatrules/steps-skip.jpg") no-repeat 0px 0px; } .status .active .heading { background: url("../threatrules/steps-over.jpg") no-repeat 0px 0px; } .status .heading { float: left; width: 20px; height: 20px; background: url("../threatrules/steps.jpg") no-repeat 0px 0px; margin-right: 5px; } .status .top { padding-top: 0px; } .status .bottom { background: url("../threatrules/steps-line-b1.jpg") no-repeat 0px 0px; } .status .bottom-active { background: url("../threatrules/steps-line-b2.jpg") no-repeat 0px 0px; }
After setting the corresponding css, next step Just write js. According to the value of $status, add class to the corresponding <li>. The js code to achieve this function is as follows:
<script type="text/javascript"> /*根据处理状态,添加或删除对应的样式名*/ function addClass(elem, className){ //增加类名 if(!elem.className){ elem.className = className; return; } var clazz = ' ' + elem.className + ' '; if(clazz.indexOf(' ' + className + ' ') === -1){ elem.className = elem.className + ' ' + className; } } var step1 = document.getElementById('tab_step1'), step2 = document.getElementById('tab_step2'), step3 = document.getElementById('tab_step3') , step4 = document.getElementById('tab_step4'), step5 = document.getElementById('tab_step5'); var status = '<?php echo $status;?>'; switch(status){ case '1': //待确认 addClass(step2.parentNode, 'active'); //parentNode即为包含step2的外一层标签,此处即为<li>标签 break; case '2': //待修复 addClass(step2.parentNode, 'active'); addClass(step3.parentNode, 'active'); break; case '3'://已关闭 addClass(step2.parentNode, 'active'); addClass(step3.parentNode, 'active'); addClass(step4.parentNode, 'active'); break; case '4': //已公开 addClass(step2.parentNode, 'active'); addClass(step3.parentNode, 'active'); addClass(step4.parentNode, 'active'); addClass(step5.parentNode, 'end bottom-active'); break; } </script>
After setting like this, change $ status is "to be repaired", the web page process is implemented as follows:
View the corresponding web page html code:
You can see that class="active"
has been added to the corresponding <li>
tag. At this point, the setting is successful and the process progress is dynamically displayed.
The above is the detailed content of Sample code sharing for dynamically displaying the progress bar of the review process status using JavaScript (picture). For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



How to use WebSocket and JavaScript to implement an online speech recognition system Introduction: With the continuous development of technology, speech recognition technology has become an important part of the field of artificial intelligence. The online speech recognition system based on WebSocket and JavaScript has the characteristics of low latency, real-time and cross-platform, and has become a widely used solution. This article will introduce how to use WebSocket and JavaScript to implement an online speech recognition system.

WebSocket and JavaScript: Key technologies for realizing real-time monitoring systems Introduction: With the rapid development of Internet technology, real-time monitoring systems have been widely used in various fields. One of the key technologies to achieve real-time monitoring is the combination of WebSocket and JavaScript. This article will introduce the application of WebSocket and JavaScript in real-time monitoring systems, give code examples, and explain their implementation principles in detail. 1. WebSocket technology

Introduction to how to use JavaScript and WebSocket to implement a real-time online ordering system: With the popularity of the Internet and the advancement of technology, more and more restaurants have begun to provide online ordering services. In order to implement a real-time online ordering system, we can use JavaScript and WebSocket technology. WebSocket is a full-duplex communication protocol based on the TCP protocol, which can realize real-time two-way communication between the client and the server. In the real-time online ordering system, when the user selects dishes and places an order

How to use WebSocket and JavaScript to implement an online reservation system. In today's digital era, more and more businesses and services need to provide online reservation functions. It is crucial to implement an efficient and real-time online reservation system. This article will introduce how to use WebSocket and JavaScript to implement an online reservation system, and provide specific code examples. 1. What is WebSocket? WebSocket is a full-duplex method on a single TCP connection.

JavaScript and WebSocket: Building an efficient real-time weather forecast system Introduction: Today, the accuracy of weather forecasts is of great significance to daily life and decision-making. As technology develops, we can provide more accurate and reliable weather forecasts by obtaining weather data in real time. In this article, we will learn how to use JavaScript and WebSocket technology to build an efficient real-time weather forecast system. This article will demonstrate the implementation process through specific code examples. We

JavaScript tutorial: How to get HTTP status code, specific code examples are required. Preface: In web development, data interaction with the server is often involved. When communicating with the server, we often need to obtain the returned HTTP status code to determine whether the operation is successful, and perform corresponding processing based on different status codes. This article will teach you how to use JavaScript to obtain HTTP status codes and provide some practical code examples. Using XMLHttpRequest

Usage: In JavaScript, the insertBefore() method is used to insert a new node in the DOM tree. This method requires two parameters: the new node to be inserted and the reference node (that is, the node where the new node will be inserted).

Vue component development: Progress bar component implementation method Preface: In Web development, the progress bar is a common UI component, often used to display the progress of operations in scenarios such as data requests, file uploads, and form submissions. In Vue.js, we can easily implement a progress bar component by customizing components. This article will introduce an implementation method and provide specific code examples. I hope it will be helpful to Vue.js beginners. Component structure and style First, we need to define the basic structure and style of the progress bar component.
