Dashboards & Visualizations

Why do I have to reload my dashboard to execute a search?

JarrenJ
Explorer

I am using Javascript to dynamically add a hash string to an input from splunk, based on its ID. it updates the value of the input but when i click Submit, it doesnt do anything. I have to refresh the page and then paste in the value for it to work. This defeats the purpose of autofilling the input field based on the file uploaded.

any help would appreciated, thanks!

EDIT:

This is my script:

$(document).ready(function () {
  $("#btn").click(function () {
      var reader = new FileReader(); //define a Reader
      var file = $("#f1")[0].files[0]; //get the File object 
      if (!file) {
          alert("no file selected");
          return;
      } //check if user selected a file

      reader.onload = function (f) {
          var file_result = this.result; // this == reader, get the loaded file "result"
          var file_wordArr = CryptoJS.lib.WordArray.create(file_result); //convert blob to WordArray
          var sha1_hash = CryptoJS.SHA1(file_wordArr); //calculate SHA1 hash
            $('#input1_3520-input').attr('value', sha1_hash);
          //document.getElementById("input1_3520-input").value = sha1_hash; //put hash into input field
          //alert("Calculated SHA1:" + sha1_hash.toString()); //output result
      };
      reader.readAsArrayBuffer(file); //read file as ArrayBuffer
  });
});

It works, it puts the generated hash into my field but to actually run the search, I need to copy the hash, reload the page and then paste it in and it works... I don't think its a timing issue. Could it be that it is only changing the text value of the input field and not that actual value?

EDIT #2:

Now, I don't need to reload the page i just need to actually type a character in the field, hit submit, then delete the added character and hit submit again and it runs the search on the hash... My only guess is that the input field isn't actually detected a value change?

0 Karma

elliotproebstel
Champion

I've seen behavior like this when my javascript had some timing issues. Can you share the dashboard XML and javascript code? Feel free to obfuscate any sensitive data.

0 Karma

JarrenJ
Explorer

thanks for the response guys, see the updated question.

0 Karma
Get Updates on the Splunk Community!

Splunk Enterprise Security: Your Command Center for PCI DSS Compliance

Every security professional knows the drill. The PCI DSS audit is approaching, and suddenly everyone's asking ...

Developer Spotlight with Guilhem Marchand

From Splunk Engineer to Founder: The Journey Behind TrackMe    After spending over 12 years working full time ...

Cisco Catalyst Center Meets Splunk ITSI: From 'Payments Are Down' to Root Cause in ...

The Problem: When Networks and Services Don't Talk Payment systems fail at a retail location. Customers are ...