Splunk Search

How to get the clicked value using javascript

madanashok
Path Finder

Hi,

Iam using simpleresultstable module with pager to show results like below.

a link

View http://www.some url
View http://www.some url
View http://www.some url

Now in application.js i use this following code to show the value when clicked.

switch (Splunk.util.getCurrentView()) {
case "dd1":
if (Splunk.Module.NullModule) {
Splunk.Module.NullModule = $.klass(Splunk.Module.NullModule, {
getModifiedContext: function() {

             var name = this.getContext().get("click.name");

               var val = this.getContext().get("click.value");
                 if (name == "a") {
                               alert(val);
              }
                return context;
            }
        });
    }
    break;

}

when i click the table it shows only the first column value in message box.

I want to get the clicked value in MessageBox.

Thanks

Tags (1)
0 Karma

joelzyla
Explorer

Jquery, which is built into Splunk, could be used.

http://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0CC8QFjAA&url=http%3A%2F%2Fapi.jq...

(the .live has been replaced with .on in the current version of Jquery, but Splunk is using version 1.6, so .live will work.

if (Splunk.util.getCurrentView() == 'your_view_name' ) {

   $(".myButtonClass").live("click", function(event){
   event.preventDefault(); 
   var txt = $(this).text();
   var url = $(this).url();
   alert(txt);
   alert(url);
   });
}
0 Karma

Ayn
Legend

What kind of drilldown are you using, row or all? You need to have drilldown set to all in your SimpleResultsTable module and then use the variable click.value2 to get the contents of the specific cell that is clicked. click.value just gives you the value of the first cell in the row clicked.

http://docs.splunk.com/Documentation/Splunk/5.0/AdvancedDev/TableChartDrilldown

madanashok
Path Finder

No I am not using any drill down here.Iam using javascript code to get the value in message box.

I found there is a possibilty to get the clicked value in message box.

The above table shows a and link columns.Iam displaying that using simpleresultstable module.When i click any cell value(second column cell value) it loads application.js file and after executing the script it shows the first column cell value only.But I want to get the link value say that(http://someurl).

0 Karma
Get Updates on the Splunk Community!

Accelerating Observability as Code with the Splunk AI Assistant

We’ve seen in previous posts what Observability as Code (OaC) is and how it’s now essential for managing ...

Integrating Splunk Search API and Quarto to Create Reproducible Investigation ...

 Splunk is More Than Just the Web Console For Digital Forensics and Incident Response (DFIR) practitioners, ...

Congratulations to the 2025-2026 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...