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 | What is broken 80% of the time by February?

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

Unlock Faster Time-to-Value on Edge and Ingest Processor with New SPL2 Pipeline ...

Hello Splunk Community,   We're thrilled to share an exciting update that will help you manage your data more ...

Splunk MCP & Agentic AI: Machine Data Without Limits

Discover how the Splunk Model Context Protocol (MCP) Server can revolutionize the way your organization uses ...