Is there a way to adjust multiple values with just one input slider? I've attempted to do so several times without success. My goal is to modify the value of 50,000 at the top of the slider as well as the value of 250k in the unique view's container. As we slide the slider forward, the 50,000 value should increment by 10,000 for each step (e.g., from 50,000 to 60,000 to 70,000 and so on up to 1,000,000). Additionally, the 250k value should increase by 50K per step (e.g., from 250k to 300k to 350k and so on up to 5M). This project is created using HTML, CSS, and JavaScript, and the codes are provided below:
const input = document.querySelector("input"),
number = document.querySelector(".slide-value"),
uniqueViews = document.querySelector(".unique_views");
input.addEventListener("input", () => {
number.textContent = input.value.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
});
.campaign {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.campaign .campaign-details {
display: flex;
align-items: center;
flex-direction: column;
width: 75%;
background: gray;
box-shadow: 5px 5px 4px rgba(0, 0, 0, .16);
border-radius: 10px;
margin-top: 60px;
padding: 20px 0;
}
.campaign .campaign-details .campaign-container .campaign-cards {
display: flex;
align-items: center;
justify-content: center;
gap: 32px;
margin: 0 10%;
}
.campaign .campaign-details .campaign-container .campaign-cards .card {
width: calc(25% - 30px);
border: 1px solid red;
height: 50px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: flex-start;
padding: 35px 30px;
}
.campaign .campaign-details .campaign-container .campaign-slider {
display: flex;
align-items: center;
justify-content: center;
}
.campaign .campaign-details .campaign-container .campaign-slider .wrapper {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 130px;
width: 100%;
border: 1px solid red;
}
.campaign .campaign-details .campaign-container .campaign-slider .wrapper .slide-value {
font-size: 27px;
font-weight: 500;
color: #333;
width: 70px;
text-align: center;
}
.campaign .campaign-details .campaign-container .campaign-slider .wrapper input {
width: 100%;
appearance: none;
height: 12px;
background-color: #bdd6f9;
...
<div class="campaign">
<h2 class="header custom-cursor">Making Influencer Campaign Simple</h2>
<div class="details campaign-details">
<div class="campaign-container">
<div class="campaign-cards">
<div class="card">
<div class="title">
<h3>Traffic</h3>
</div>
</div>
</div>
<div class="campaign-slider">
<div class="wrapper">
<span class="slide-value">50,000</span>
<input type="range" min="50000" step="10000" max="1000000" value="50000" />
<div class="min-max-value">
<p>Min: ₹50,000</p>
<p>Max: ₹1,000,000</p>
</div>
</div>
</div>
...
</div>
</div>
</div>