Troubleshooting issues with Bootstrap-slider.js and class functionality

My current project involves creating a page that features two sliders for user interaction. Users select values using these sliders, which are then displayed by the script. Additionally, the script calculates the product of the two values along with some factors and displays them. The coding seemed simple enough until an issue arose when I implemented the class="ms-slider". Without it, the formatting suffers, but including it disrupts the functionality of the script.

<form method="post" action="#">
//Slider #1
<input type="range" class="ms-slider" name="viewers" id="value1" value="0" min="0" max="200000" step='1000'  data-highlight="true" onchange="calc" data-slider-ticks="[0, 100000, 200000]" data-slider-ticks-snap-bounds="3" data-slider-value="10000" data-slider-ticks-labels='["0", "100,000", "200,000"]'/>
//Slider #2   
<input type="range" class="ms-slider" name="price" id="value2" value="0" min="0" max="16" step='1' data-highlight="true" onchange="calc" data-slider-ticks="[0, 8, 16]" data-slider-ticks-snap-bounds="3" data-slider-value="8" data-slider-ticks-labels='["$0", "$8", "$16"]'/>
    
//output fields - displays slider values
   <input type="text" id="value11" name="value11"/>
   <input type="text" id="value21" name="value21"/>
    
//output fields - display the multiplied values   
   <input type="text" id="total1" name="total1"/>
   <input type="text" id="total2" name="total2"/> 
    
</form>


<script>
// On any change in form.
$("form :input").change(function() {
    // Fetch selected options.
    var value1 = $('form #value1').val();
    var value2 = $('form #value2').val();
       
    // Display values in text field.
    $('form #value11').val((value1));
    $('form #value21').val((value2));
    $('form #total1').val((value1 * value2) * 0.01);
    $('form #total2').val((value1 * value2) * 0.05);
});
</script>

Answer №1

When it comes to the id values, uniqueness is key (value1 and value2). The initial declarations can be found within the range of input elements. Let's uncover the duplicates:

  <input type="text" id="value1" name="value1"/>
  <input type="text" id="value2" name="value2"/>

The issue at hand is that there are multiple instances where tags share the same ids: specifically value1 and value2. There exist two tags with an id of value1, as well as two tags with an id of value2. Keep in mind that all id values need to be unique for your code to function effectively.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Leveraging Next.JS for static site generation with Apollo client-side data fetching

Utilizing Next.JS SSG has greatly enhanced the loading speed of my website. However, I am facing a challenge where I need to fetch some data client-side that is specific to the logged-in user. For example, imagine a YouTube-like website with a Video page ...

formatting dates in React.js with JavaScript code

Currently, I am using React JS for my form. When loading the date into the text box, it appears in a different format as shown below: <Form.Control type="text" disabled size="sm" placeholder=& ...

Is there a specific method or function that can effectively translate special characters such as into their corresponding representations?

When a user provides input for my script using shell arguments, it would look something like this: Kek kek\nkek\tkek\x43 After receiving the input, Javascript interprets my parameter in a specific way: var parameter="Kek kek\&bs ...

jQuery navigation bar mouse hover glitch

I've created a sidebar using jQuery, but I'm facing an issue. When I hover my mouse quickly on the sidebar and then move to the "red" area, the 3rd item should open a submenu, but it doesn't. How can I fix this? Here's my jsfiddle with ...

Ensuring the functionality of WebAPI endpoints through JavaScript

Is there a foolproof way to ensure that your WebAPI controller routes stay aligned with the client-side requirements? Let's say you have a BooksController for your WebAPI. On the client side, a method is invoked by calling the endpoint like this: $. ...

The power of Ionic 2 combined with the Web Audio API

I am currently developing an Ionic 2 application that requires access to the user's microphone. When working on a web platform, I would typically use the following code snippet to obtain microphone access. navigator.getUserMedia = (navigator['ge ...

Mastering the utilization of custom input events in PrimeNG with Angular

I am currently working on an Angular 16 project. Within this project, I have implemented a number input field that is being validated using formControls. To make my work more efficient, especially since this input is used frequently, I decided to encapsula ...

Tips for implementing autocomplete in a textbox on an ASP.NET website with jQuery

Make sure to include a control named ProductType of type textbox in your .aspx page. [WebMethod(EnableSession = true)] public static List<string> GetAutoCompleteDataProduct(string ProductType) { // string pid = ""; ProductMas ...

Create a function that adds an event listener to a button that is

My dynamic radio buttons, text area, and click events are not functioning properly for the add and remove button. I attempted to use jQuery's .on function with no success: $("#TextBoxesGroup")‌​.on("click", ".abc", (function () { //some script } ...

Button Click Not Allowing Webpage Scroll

I am currently in the process of developing a website that aims to incorporate a significant amount of motion and interactivity. The concept I have devised involves a scenario where clicking on a button from the "main menu" will trigger a horizontal and ve ...

How can I gather information from members who have already signed up?

I have a form that submits data to the Angular Firebase database. Once the form is submitted, I want to display the previously submitted data in the form if the user signs in again. Below is my .ts file: import { Component, OnInit } from '@angular/c ...

The specified path does not contain any of these files

Encountered an error while attempting to run a react native app on an android emulator: None of these files exist: * src\components\spacer\spacer.component(.native|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.js|.na ...

A cookie designed to store and retain the preferred CSS stylesheet choice

I'm looking to create a cookie that will store the preference for a specific CSS stylesheet. I currently have a function in place that allows me to switch between stylesheets: function swapStylesheet(sheet){ document.getElementById('pagestyl ...

Encountered a problem when incorporating delay functions into redux-saga testing using the Redux Saga Test Plan library

I am facing a challenge while trying to test my redux-saga functions using the Redux Saga Test Plan library. The issue arises due to delay functions present in my saga. All tests pass smoothly without any errors when I remove the line containing yield del ...

terminate server through the router

I have created an express application like the following: const express = require('express') const app = express(); app.use(express.static(path.join(__dirname, 'public'))); app.post('/close', async (_, res) => { res.sta ...

Making two images of different sizes have the same height and completely fill the width of their parent container

I need help making two images in a parent element with a width of 'col-9' have equal heights and fill the width. The images can vary in size, so I'm looking for a simpler solution than using Flex and calculating aspect ratios every time. I a ...

Having trouble with JQuery blur and enter key functionality not working properly

I'm currently utilizing the code below for inline editing. I am looking to trigger ajax when either the enter key is pressed or the user clicks away (blur). While everything works fine when the enter key is pressed, the AJAX call does not fire on bl ...

performing an asynchronous mapping operation to update the elements of the array

I am working with an array that needs to undergo async.map processing. The parallel execution on each array object seems to be functioning correctly, with results logged as "Result for ...". However, the issue arises when the return callback from the itera ...

Is there a way to access the value of a textBox within an AJAX method?

Upon clicking the Log In button, I am faced with two issues. Firstly, when prompted by localhost to allow access, the pop-up disappears in a split second after one click. Only upon double-clicking does it persist at the bottom of the screen, allowing the A ...

Fix Uncaught Syntax Error: Unexpected character ">"

I have developed a function to convert text into a base64 image within my Cordova App. It is functioning properly, however, in some devices an Unexpected token error occurs within the script. Below is the function code: function convertTextToImage(m ...