Dashboards & Visualizations

Access token value from a textbox in html dashboard

komalg
New Member

Hello,

I am trying to access the value of a text input box in an html dashboard to pass to the saved search being called when submit button is pressed.
I am unable to get the value so far. Can someone pls tell me what I am missing?

Thanks,
Komal


    <div id="panel2" class="dashboard-cell" style="width: 100%;">
        <div class="dashboard-panel clearfix">
            <div class="fieldset">
                <div class="input input-text" id="text1">
        <label> </label>
    </div>
            </div>

….

Form Inputs section of the dashbaord

//
// VIEWS: FORM INPUTS
//

    var text1 = new TextInput({
        "id": "text1",
        "searchWhenChanged": true,
        "value": "$appname_tok$",
        "el": $('#text1')
    }, {tokens: true}).render();

In my saved search I am saying ….$appname_tok$ but it does not pick up the value entered.
I have referenced this document already.
http://dev.splunk.com/view/webframework-codeexamples/SP-CAAAE5V
Any pointers?

Thanks a lot.

Tags (1)
0 Karma

niketn
Legend

@komalg any reason for converting dashboard to html? If you want to pass selected textbox input value to your search on click of submit button this can be done directly using Simple XML Dashboard. So kindly explain the need for html dashboard. Following is a run anywhere example.

<form>
  <label>Text Box to Saved Search</label>
  <fieldset submitButton="true">
    <input type="text" token="appname_tok">
      <label>text1</label>
    </input>
  </fieldset>
  <row>
    <panel>
      <table>
        <search>
          <query>
            | makeresults
            | fields - _time
            | eval SelectedText="$appname_tok$"
          </query>
        </search>
      </table>
    </panel>
  </row>
</form>
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

DavidHourani
Super Champion

Try without the quotes... "value": $appname_tok$ are the results the same ? Also try to see what's in the token, make an html panel and display it to make sure it's populating properly.

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Tech Talk Recap | Mastering Threat Hunting

Mastering Threat HuntingDive into the world of threat hunting, exploring the key differences between ...

Observability for AI Applications: Troubleshooting Latency

If you’re working with proprietary company data, you’re probably going to have a locally hosted LLM or many ...

Splunk AI Assistant for SPL vs. ChatGPT: Which One is Better?

In the age of AI, every tool promises to make our lives easier. From summarizing content to writing code, ...