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!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...