Dashboards & Visualizations

Why is my javascript code not working in my dashboard?

mrao123
Engager

So, I am trying to get a progress bar button in Splunk Dashboard, which will work on click button.
Here is what i done :

I have created a 2 files under /opt/splunk/etc/apps/MY_APP/appserver/static/button.js and button.css

code for button.js is :

*****************************************************
function move() {
  var elem = document.getElementById("myBar");   
  var width = 1;
  var id = setInterval(frame, 10);
  function frame() {
    if (width >= 100) {
      clearInterval(id);
    } else {
      width++; 
      elem.style.width = width + '%'; 
    }
  }
}
*****************************************

Code for prog.css is :
******************************************
#myProgress {
  width: 100%;
  background-color: #ddd;
}

#myBar {
  width: 1%;
  height: 30px;
  background-color: #4CAF50;
}

************************************************

Now here is my code for Dashboard where i can calling button.css and button.js file ( button.css works fine)

  testdash

    <panel>
      <html>




Click Me 





***********************************************

please find an Image below for your reference .

Button.js is still not working.

Any suggestion ?alt text

0 Karma
1 Solution

mrao123
Engager

I fixed it of my own ..

Ans : by clearing the browser cache..

View solution in original post

nickhills
Ultra Champion

In most cases you can use the _bump url to bust the cache for you

https://<yourSplunk>/en-US/_bump

Give it a try next time you update your js

If my comment helps, please give it a thumbs up!

mrao123
Engager

I fixed it of my own ..

Ans : by clearing the browser cache..

Get Updates on the Splunk Community!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...