<?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: How to set initial value of text input in a form using eval or JavaScript..? in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-set-initial-value-of-text-input-in-a-form-using-eval-or/m-p/301352#M19186</link>
    <description>&lt;P&gt;Create a lookup mylookup.csv like below&lt;BR /&gt;
day_of_w, No&lt;BR /&gt;
......................&lt;BR /&gt;
Sunday   ,0&lt;BR /&gt;
Monday ,1&lt;BR /&gt;
Tuesday ,2&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
Saturday,6&lt;/P&gt;

&lt;PRE&gt;|inputlookup mylookup.csv | eval date_wday=strftime(now(),"%w") | eval No=if(date_wday==No,0,No) | sort No | table day_of_w

&lt;/PRE&gt;</description>
    <pubDate>Tue, 29 Sep 2020 12:54:09 GMT</pubDate>
    <dc:creator>pradeepkumarg</dc:creator>
    <dc:date>2020-09-29T12:54:09Z</dc:date>
    <item>
      <title>How to set initial value of text input in a form using eval or JavaScript..?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-set-initial-value-of-text-input-in-a-form-using-eval-or/m-p/301351#M19185</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I am looking for a sample to set a initial value dynamically using eval or JavaScript.&lt;BR /&gt;
e.g. set "Monday" or "Tuesday" as a initial value when a form is opened.&lt;/P&gt;

&lt;P&gt;I have this very simple form like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;form&amp;gt;
  &amp;lt;label&amp;gt;sample&amp;lt;/label&amp;gt;
  &amp;lt;fieldset submitButton="false"&amp;gt;
    &amp;lt;input type="text" token="a"&amp;gt;
      &amp;lt;label&amp;gt;Today&amp;lt;/label&amp;gt;
      &amp;lt;initialValue&amp;gt;&amp;lt;/initialValue&amp;gt;
    &amp;lt;/input&amp;gt;
  &amp;lt;/fieldset&amp;gt;
&amp;lt;/form&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and I want to set a value for  depending on a day the form is accessed.&lt;BR /&gt;
I am looking for a way to do this by eval tag or JavaScript extention, but I have not found any sample for this kind of input value initialization.&lt;/P&gt;

&lt;P&gt;Any simple sample would be appreciated!&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2017 04:18:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-set-initial-value-of-text-input-in-a-form-using-eval-or/m-p/301351#M19185</guid>
      <dc:creator>melonman</dc:creator>
      <dc:date>2017-02-16T04:18:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to set initial value of text input in a form using eval or JavaScript..?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-set-initial-value-of-text-input-in-a-form-using-eval-or/m-p/301352#M19186</link>
      <description>&lt;P&gt;Create a lookup mylookup.csv like below&lt;BR /&gt;
day_of_w, No&lt;BR /&gt;
......................&lt;BR /&gt;
Sunday   ,0&lt;BR /&gt;
Monday ,1&lt;BR /&gt;
Tuesday ,2&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
Saturday,6&lt;/P&gt;

&lt;PRE&gt;|inputlookup mylookup.csv | eval date_wday=strftime(now(),"%w") | eval No=if(date_wday==No,0,No) | sort No | table day_of_w

&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Sep 2020 12:54:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-set-initial-value-of-text-input-in-a-form-using-eval-or/m-p/301352#M19186</guid>
      <dc:creator>pradeepkumarg</dc:creator>
      <dc:date>2020-09-29T12:54:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to set initial value of text input in a form using eval or JavaScript..?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-set-initial-value-of-text-input-in-a-form-using-eval-or/m-p/301353#M19187</link>
      <description>&lt;P&gt;Thank you for your input, and I understand what you showed. But could this search result be used for setting initial value for input as a text? &lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2017 05:54:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-set-initial-value-of-text-input-in-a-form-using-eval-or/m-p/301353#M19187</guid>
      <dc:creator>melonman</dc:creator>
      <dc:date>2017-02-16T05:54:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to set initial value of text input in a form using eval or JavaScript..?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-set-initial-value-of-text-input-in-a-form-using-eval-or/m-p/301354#M19188</link>
      <description>&lt;P&gt;You can use a drop down and use&lt;BR /&gt;
 &lt;CODE&gt;      &amp;lt;selectFirstChoice&amp;gt;true&amp;lt;/selectFirstChoice&amp;gt; &lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;I'm sure there must be a way to populate text box as well&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2017 05:57:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-set-initial-value-of-text-input-in-a-form-using-eval-or/m-p/301354#M19188</guid>
      <dc:creator>pradeepkumarg</dc:creator>
      <dc:date>2017-02-16T05:57:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to set initial value of text input in a form using eval or JavaScript..?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-set-initial-value-of-text-input-in-a-form-using-eval-or/m-p/301355#M19189</link>
      <description>&lt;P&gt;You can give the input an id in Simple XML, get that input by its id in your js code and set its &lt;CODE&gt;default&lt;/CODE&gt; setting. Should look something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...
  type="text" token="a" id="textInput"&amp;gt;
    &amp;lt;label&amp;gt;Today&amp;lt;/label&amp;gt;
    ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And in js:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...
var textInput = mvc.Components.get("textInput");
textInput.settings.set("default", "some value or dynamic text");
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can do the same with initialValue, though I doubt you really need that. Docs for that are &lt;A href="http://docs.splunk.com/Documentation/WebFramework"&gt;here&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2017 14:01:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-set-initial-value-of-text-input-in-a-form-using-eval-or/m-p/301355#M19189</guid>
      <dc:creator>jeffland</dc:creator>
      <dc:date>2017-02-16T14:01:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to set initial value of text input in a form using eval or JavaScript..?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-set-initial-value-of-text-input-in-a-form-using-eval-or/m-p/301356#M19190</link>
      <description>&lt;P&gt;Thank you! Now I can start adding some more stuff for text box initialization ...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;form script="sample.js"&amp;gt;
  &amp;lt;label&amp;gt;sample&amp;lt;/label&amp;gt;
  &amp;lt;fieldset submitButton="false"&amp;gt;
    &amp;lt;input type="text" token="token1" id="id1"&amp;gt;
      &amp;lt;label&amp;gt;Text Input&amp;lt;/label&amp;gt;
    &amp;lt;/input&amp;gt;
  &amp;lt;/fieldset&amp;gt;
&amp;lt;/form&amp;gt;

$ cat sample.js
require(["splunkjs/mvc", "splunkjs/mvc/simplexml/ready!"], function(mvc) {
     var date1 = new Date();
     var year = date1.getFullYear();
     var val1 = mvc.Components.get('id1');
     val1.settings.set("default", year);
});
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 17 Feb 2017 00:34:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-set-initial-value-of-text-input-in-a-form-using-eval-or/m-p/301356#M19190</guid>
      <dc:creator>melonman</dc:creator>
      <dc:date>2017-02-17T00:34:41Z</dc:date>
    </item>
  </channel>
</rss>

