search
HomeWeb Front-endJS TutorialSample 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:

Sample code sharing for dynamically displaying the progress bar of the review process status using JavaScript (picture)

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 id="漏洞处理状态">漏洞处理状态</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 = &#39; &#39; + elem.className + &#39; &#39;; 
  if(clazz.indexOf(&#39; &#39; + className + &#39; &#39;) === -1){ 
      elem.className = elem.className + &#39; &#39; + className; 
  } 
} 
 var step1 = document.getElementById(&#39;tab_step1&#39;), 
   step2 = document.getElementById(&#39;tab_step2&#39;), 
   step3 = document.getElementById(&#39;tab_step3&#39;) , 
   step4 = document.getElementById(&#39;tab_step4&#39;), 
   step5 = document.getElementById(&#39;tab_step5&#39;); 
 var status = &#39;<?php echo $status;?>&#39;; 
 switch(status){ 
   case &#39;1&#39;: //待确认 
     addClass(step2.parentNode, &#39;active&#39;); //parentNode即为包含step2的外一层标签,此处即为<li>标签 
     break; 
   case &#39;2&#39;: //待修复 
      addClass(step2.parentNode, &#39;active&#39;); 
      addClass(step3.parentNode, &#39;active&#39;); 
     break; 
   case &#39;3&#39;://已关闭 
     addClass(step2.parentNode, &#39;active&#39;); 
     addClass(step3.parentNode, &#39;active&#39;); 
     addClass(step4.parentNode, &#39;active&#39;); 
     break; 
   case &#39;4&#39;: //已公开 
     addClass(step2.parentNode, &#39;active&#39;); 
     addClass(step3.parentNode, &#39;active&#39;); 
     addClass(step4.parentNode, &#39;active&#39;); 
     addClass(step5.parentNode, &#39;end bottom-active&#39;); 
     break; 
 } 
</script>

After setting like this, change $ status is "to be repaired", the web page process is implemented as follows:

Sample code sharing for dynamically displaying the progress bar of the review process status using JavaScript (picture)

View the corresponding web page html code:

Sample code sharing for dynamically displaying the progress bar of the review process status using JavaScript (picture)

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!

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
Python vs. JavaScript: Community, Libraries, and ResourcesPython vs. JavaScript: Community, Libraries, and ResourcesApr 15, 2025 am 12:16 AM

Python and JavaScript have their own advantages and disadvantages in terms of community, libraries and resources. 1) The Python community is friendly and suitable for beginners, but the front-end development resources are not as rich as JavaScript. 2) Python is powerful in data science and machine learning libraries, while JavaScript is better in front-end development libraries and frameworks. 3) Both have rich learning resources, but Python is suitable for starting with official documents, while JavaScript is better with MDNWebDocs. The choice should be based on project needs and personal interests.

From C/C   to JavaScript: How It All WorksFrom C/C to JavaScript: How It All WorksApr 14, 2025 am 12:05 AM

The shift from C/C to JavaScript requires adapting to dynamic typing, garbage collection and asynchronous programming. 1) C/C is a statically typed language that requires manual memory management, while JavaScript is dynamically typed and garbage collection is automatically processed. 2) C/C needs to be compiled into machine code, while JavaScript is an interpreted language. 3) JavaScript introduces concepts such as closures, prototype chains and Promise, which enhances flexibility and asynchronous programming capabilities.

JavaScript Engines: Comparing ImplementationsJavaScript Engines: Comparing ImplementationsApr 13, 2025 am 12:05 AM

Different JavaScript engines have different effects when parsing and executing JavaScript code, because the implementation principles and optimization strategies of each engine differ. 1. Lexical analysis: convert source code into lexical unit. 2. Grammar analysis: Generate an abstract syntax tree. 3. Optimization and compilation: Generate machine code through the JIT compiler. 4. Execute: Run the machine code. V8 engine optimizes through instant compilation and hidden class, SpiderMonkey uses a type inference system, resulting in different performance performance on the same code.

Beyond the Browser: JavaScript in the Real WorldBeyond the Browser: JavaScript in the Real WorldApr 12, 2025 am 12:06 AM

JavaScript's applications in the real world include server-side programming, mobile application development and Internet of Things control: 1. Server-side programming is realized through Node.js, suitable for high concurrent request processing. 2. Mobile application development is carried out through ReactNative and supports cross-platform deployment. 3. Used for IoT device control through Johnny-Five library, suitable for hardware interaction.

Building a Multi-Tenant SaaS Application with Next.js (Backend Integration)Building a Multi-Tenant SaaS Application with Next.js (Backend Integration)Apr 11, 2025 am 08:23 AM

I built a functional multi-tenant SaaS application (an EdTech app) with your everyday tech tool and you can do the same. First, what’s a multi-tenant SaaS application? Multi-tenant SaaS applications let you serve multiple customers from a sing

How to Build a Multi-Tenant SaaS Application with Next.js (Frontend Integration)How to Build a Multi-Tenant SaaS Application with Next.js (Frontend Integration)Apr 11, 2025 am 08:22 AM

This article demonstrates frontend integration with a backend secured by Permit, building a functional EdTech SaaS application using Next.js. The frontend fetches user permissions to control UI visibility and ensures API requests adhere to role-base

JavaScript: Exploring the Versatility of a Web LanguageJavaScript: Exploring the Versatility of a Web LanguageApr 11, 2025 am 12:01 AM

JavaScript is the core language of modern web development and is widely used for its diversity and flexibility. 1) Front-end development: build dynamic web pages and single-page applications through DOM operations and modern frameworks (such as React, Vue.js, Angular). 2) Server-side development: Node.js uses a non-blocking I/O model to handle high concurrency and real-time applications. 3) Mobile and desktop application development: cross-platform development is realized through ReactNative and Electron to improve development efficiency.

The Evolution of JavaScript: Current Trends and Future ProspectsThe Evolution of JavaScript: Current Trends and Future ProspectsApr 10, 2025 am 09:33 AM

The latest trends in JavaScript include the rise of TypeScript, the popularity of modern frameworks and libraries, and the application of WebAssembly. Future prospects cover more powerful type systems, the development of server-side JavaScript, the expansion of artificial intelligence and machine learning, and the potential of IoT and edge computing.

See all articles

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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.