Dashboards & Visualizations

help to add submitbutton in panel

jip31
Motivator

hi

is it possible to use a submitButton in a panel?
I would like to add it in the xml below
thanks

      <input type="text" token="tok_filterhost" searchWhenChanged="true">
        <label>Filter by hostname</label>
        <default>*</default>
        <initialValue>*</initialValue>
      </input>
0 Karma
1 Solution

dmarling
Builder

This is unfortunately not supported natively in splunk. There are some work arounds that you can find on answers. Here's some suggested answers to review:

https://answers.splunk.com/answers/346916/submit-button-per-panel-in-simple-xml.html

https://answers.splunk.com/answers/683916/submit-button-inside-a-panel-is-not-working.html

If this comment/answer was helpful, please up vote it. Thank you.

View solution in original post

0 Karma

vnravikumar
Champion

Hi

Try the below code

<form script="button.js">
  <init>
    <set token="hostname">*</set>
  </init>
  <label>submit button</label>
  <fieldset submitButton="false"></fieldset>
  <row depends="$hide$">
    <html>
      <style>
        .btn-search{
            color: #fff;
            padding: 6px 15px;
            font-weight: 500;
            background-color: #5cc05c;
            border: transparent;
            display: inline-block;
            height: auto;
            line-height: 20px;
            font-size: 14px;
              box-sizing: border-box;
              margin-bottom: 0;
              text-align: center;
            vertical-align: middle;
            cursor: pointer;
            border-radius: 3px;
            white-space: nowrap;
         }
         .btn-search:hover{
            background-color: #40a540;
            border-color: transparent;
            color: #fff;
            box-shadow: inset 0 -2px 0 rgba(0,0,0,.1);
            text-decoration: none;
            text-shadow: none;
            filter: none;
         }
      </style>
    </html>
  </row>
  <row>
    <panel>
      <input type="text" searchWhenChanged="false" id="host">
        <label>Filter by hostname</label>
        <default>*</default>
        <initialValue>*</initialValue>
      </input>
      <html>
         <input type="button" value="Search" id="submit_host" class="btn-search"/>
       </html>
      <table>
        <search>
          <query>index=_internal host="$hostname$" |stats count by source</query>
          <earliest>-24h@h</earliest>
          <latest>now</latest>
        </search>
        <option name="drilldown">none</option>
      </table>
    </panel>
    <panel>
      <table>
        <search>
          <query>index=_internal |stats count by sourcetype</query>
          <earliest>-24h@h</earliest>
          <latest>now</latest>
        </search>
        <option name="drilldown">none</option>
      </table>
    </panel>
  </row>
</form>

javascript

require([
    "jquery", 
    "splunkjs/mvc", 
    "splunkjs/mvc/simplexml/ready!"], function($, mvc) {
        var defaultTokenModel = mvc.Components.get("submitted");
        $( "#submit_host" ).click(function() {
            var hostname= $('#host input[type="text"]').val();
            defaultTokenModel.set("hostname",hostname);
          });
    });

dmarling
Builder

This is unfortunately not supported natively in splunk. There are some work arounds that you can find on answers. Here's some suggested answers to review:

https://answers.splunk.com/answers/346916/submit-button-per-panel-in-simple-xml.html

https://answers.splunk.com/answers/683916/submit-button-inside-a-panel-is-not-working.html

If this comment/answer was helpful, please up vote it. Thank you.
0 Karma
Get Updates on the Splunk Community!

Index This | When is October more than just the tenth month?

October 2025 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Observe and Secure All Apps with Splunk

  Join Us for Our Next Tech Talk: Observe and Secure All Apps with SplunkAs organizations continue to innovate ...

What’s New & Next in Splunk SOAR

 Security teams today are dealing with more alerts, more tools, and more pressure than ever.  Join us for an ...