Splunk Search

Unabe to get the search result in text box using javascript inside html module

madanashok
Path Finder

Hi,

Just have a look at this code

< module name="HiddenSearch" layoutPanel="panel_row2_col1"  autoRun="True">
    < param name="search">index="someindex" sourcetype="somesourcetype" |top  limit=1 E2E_busProcType< /param>
    < param name="earliest">-7d< /param>
        < module name="HTML" layoutPanel="panel_row2_col1">
        < param  name="html">
                <![CDATA[

< script type="text/javascript" >
          function call()
          {
       document.getElementById("a").value=$results[0].E2E_busProcType$;
          alert(document.getElementById("a").value);
          }

         < /script>
< input type="text" id="a">< /input>
< input type="button" onclick="call()" value="clickme">< /input>
< /param>



        < /module>

when i click the button i want to get the search result in the textbox.
This click is showing the value in text box when i place static text in alert box.

How do i get the search value.Is that possible to get or not.

Tags (1)
0 Karma

rakesh_498115
Motivator

Hi..
Yeah its Possible in splunk !!!
Use the Following code snippet in your code.

< input type="button" onclick="call($results[0].E2E_busProcType$)" value="clickme">< /input>

and inside the javascript function do the following changes..

function call(var arg)
{
document.getElementById("a").value=arg;
alert(document.getElementById("a").value);
}

Now you can the see value displayed in the alert box.

0 Karma

sideview
SplunkTrust
SplunkTrust

Please let me talk you out of this. It's not a good idea. What are you actually trying to do? If you want a text input there's the TextField module, if you want a button there's the Button module. If you want to attach custom JS to the page there's the CustomBehavior module. Anything here that works is going to work only with many asterisks and pitfalls.

Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer at Splunk .conf24 ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...