<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: HTML Dashboard: How to use Javascript to change text input? in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/HTML-Dashboard-How-to-use-Javascript-to-change-text-input/m-p/199286#M12462</link>
    <description>&lt;P&gt;have you solved this issue? i and trying to do the same thing. thanks in advance!&lt;/P&gt;</description>
    <pubDate>Tue, 17 Nov 2015 02:31:23 GMT</pubDate>
    <dc:creator>paulstark</dc:creator>
    <dc:date>2015-11-17T02:31:23Z</dc:date>
    <item>
      <title>HTML Dashboard: How to use Javascript to change text input?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/HTML-Dashboard-How-to-use-Javascript-to-change-text-input/m-p/199285#M12461</link>
      <description>&lt;P&gt;I have trouble in using JS to change my text input from a comma list to convert search to a list of " OR ...OR" statement.&lt;BR /&gt;
So if my input text is "1,2,3,4", then my query after converting should look like: sourcetype=mydata id=1 OR id=2 OR id=3 OR id=4 | .....;&lt;BR /&gt;
However, when I inspect the query in search box, it is showing:&lt;BR /&gt;
sourcetype=mydata id=1,2,3,4. Does anyone has anyidea? Following is my code&lt;BR /&gt;
    var ids = new String("$myTextValue$");&lt;BR /&gt;
        ids     = ids.replace( " ","" );&lt;BR /&gt;
        ids     = ids.split( "," );&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    var ids_str = [];
    for( var i = 0; i &amp;lt; ids.length; i++ )
    {
      ids_str.push( "id=" + ids[i] );
    }

    var newComputedValue = ids_str.join( " OR " );

    var search1qry = "sourcetype=mydata " + newComputedValue ;

    var search1 = new SearchManager({
        "id": "search1",
        "earliest_time": "$earliest$",
        "cancelOnUnload": true,
        "search": search1qry,
        "status_buckets": 0,
        "latest_time": "$latest$",
        "app": utils.getCurrentApp(),
        "auto_cancel": 90,
        "preview": true
    }, {tokens: true, tokenNamespace: "submitted"});
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 17 Jun 2014 06:44:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/HTML-Dashboard-How-to-use-Javascript-to-change-text-input/m-p/199285#M12461</guid>
      <dc:creator>benjaminlin1019</dc:creator>
      <dc:date>2014-06-17T06:44:02Z</dc:date>
    </item>
    <item>
      <title>Re: HTML Dashboard: How to use Javascript to change text input?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/HTML-Dashboard-How-to-use-Javascript-to-change-text-input/m-p/199286#M12462</link>
      <description>&lt;P&gt;have you solved this issue? i and trying to do the same thing. thanks in advance!&lt;/P&gt;</description>
      <pubDate>Tue, 17 Nov 2015 02:31:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/HTML-Dashboard-How-to-use-Javascript-to-change-text-input/m-p/199286#M12462</guid>
      <dc:creator>paulstark</dc:creator>
      <dc:date>2015-11-17T02:31:23Z</dc:date>
    </item>
    <item>
      <title>Re: HTML Dashboard: How to use Javascript to change text input?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/HTML-Dashboard-How-to-use-Javascript-to-change-text-input/m-p/199287#M12463</link>
      <description>&lt;P&gt;The problem with this code is in this part:&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;var ids = new String("$myTextValue$");&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;When i do :&lt;BR /&gt;
var ids = new String("1,2,3,4");&lt;BR /&gt;
then i get an object which is not string. It's because I'm doing a string object out of a string object which is wrong approach - &lt;A href="http://stackoverflow.com/questions/5750656/whats-the-point-of-new-stringx-in-javascript"&gt;http://stackoverflow.com/questions/5750656/whats-the-point-of-new-stringx-in-javascript&lt;/A&gt; for reference.&lt;/P&gt;

&lt;P&gt;So instead of doing this try just:&lt;BR /&gt;
&lt;STRONG&gt;var ids = $myTextValue$;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Nov 2015 08:36:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/HTML-Dashboard-How-to-use-Javascript-to-change-text-input/m-p/199287#M12463</guid>
      <dc:creator>piUek</dc:creator>
      <dc:date>2015-11-17T08:36:46Z</dc:date>
    </item>
    <item>
      <title>Re: HTML Dashboard: How to use Javascript to change text input?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/HTML-Dashboard-How-to-use-Javascript-to-change-text-input/m-p/199288#M12464</link>
      <description>&lt;P&gt;In this context,I don't see the point of using javascript...&lt;BR /&gt;
Indeed I guess you could transform the token value simply from you Simple XML dashboard code !&lt;BR /&gt;
You just need to add :&lt;BR /&gt;
&lt;CODE&gt;&lt;BR /&gt;
replace("$myTextValue$", ",", " OR ")&lt;BR /&gt;
&lt;/CODE&gt; inside your input ...&lt;/P&gt;

&lt;P&gt;However maybe I didn't get your context properly ...&lt;/P&gt;</description>
      <pubDate>Tue, 17 Oct 2017 09:09:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/HTML-Dashboard-How-to-use-Javascript-to-change-text-input/m-p/199288#M12464</guid>
      <dc:creator>gdiogo</dc:creator>
      <dc:date>2017-10-17T09:09:44Z</dc:date>
    </item>
  </channel>
</rss>

