Dashboards & Visualizations

how change the value of a token in JS?

renanprado96
Path Finder

I want to insert the value of a date on a token:
I will choose for INPUT HTML.
Clicking a <button>, I wanted to set the chosen date in token

<input type="date" id="myDate" name="bday" min="2015-01-02" max="2030-01-02">
<button onclick="setarToken();"> Mostrar data </button>

I made a function like this:

function setarToken(){
    var myDateFn = document.getElementById("myDate").value;   // Here get the date of INPUT

     // And here I have that insert the date(myDateFn) in the token 
    // Something like
           $myToken$ = myDateFn ;
}

Thanks!

0 Karma

elliotproebstel
Champion

The code for getting and setting token values via JavaScript looks like this:

// Access the "default" token model
var tokens = mvc.Components.get("default");

// Retrieve the value of a token $mytoken$
var tokenValue = tokens.get("mytoken");

// Change the value of a token $mytoken$
tokens.set("mytoken", "this is the new value");

Those are taken directly from the Splunk developer guide. I'd recommend starting at the section called "Bind data using tokens". It's pretty short and straightforward.

0 Karma

sdawsonkg
Path Finder

if you convert simple xml to html, you still will not be able to decide the ids for the input tags, it will be something like

Get Updates on the Splunk Community!

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...