Getting Data In

Drilldown on text input

jiaqya
Builder

i put in some data in a text input and press enter, can i link it to another dashboard upon pressing enter key ?
basically drilldown from text input + press enter key

i am able to drill down on clicks, but not on enter key.

or any other way of achieving this ?

Tags (1)
0 Karma
1 Solution

kamlesh_vaghela
SplunkTrust
SplunkTrust

Hi @jiaqya

Can you please try this example? This code will open a google with search parameter passed in the text box.

test.xml

<form script="test.js">
  <label>dashboard test</label>
  <fieldset submitButton="false">
    <input type="text" token="searchTxt" id="searchTxt_id">
      <label>field1</label>
    </input>
  </fieldset>
</form>

test.js

require(["jquery", "splunkjs/mvc","splunkjs/mvc/utils","splunkjs/mvc/simplexml/ready!"], function($, mvc, utils) {

$(document).ready(function() {
    $($('input[id^="searchTxt_id_"]')[0]).keypress(function (event) {
        var key = (event.keyCode ? event.keyCode : event.which);
        if(key == 13)  // the enter key code
        {
            utils.redirect("https://www.google.com/search?q="+$($('input[id^="searchTxt_id_"]')[0]).val()
,"_blank");
            return false;  
        }
    });
});
});

Thanks

View solution in original post

kamlesh_vaghela
SplunkTrust
SplunkTrust

Hi @jiaqya

Can you please try this example? This code will open a google with search parameter passed in the text box.

test.xml

<form script="test.js">
  <label>dashboard test</label>
  <fieldset submitButton="false">
    <input type="text" token="searchTxt" id="searchTxt_id">
      <label>field1</label>
    </input>
  </fieldset>
</form>

test.js

require(["jquery", "splunkjs/mvc","splunkjs/mvc/utils","splunkjs/mvc/simplexml/ready!"], function($, mvc, utils) {

$(document).ready(function() {
    $($('input[id^="searchTxt_id_"]')[0]).keypress(function (event) {
        var key = (event.keyCode ? event.keyCode : event.which);
        if(key == 13)  // the enter key code
        {
            utils.redirect("https://www.google.com/search?q="+$($('input[id^="searchTxt_id_"]')[0]).val()
,"_blank");
            return false;  
        }
    });
});
});

Thanks

jiaqya
Builder

this works as expected

0 Karma
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 ...