<?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 can i change type of inputText in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/how-can-i-change-type-of-inputText/m-p/244018#M45119</link>
    <description>&lt;P&gt;Hi @jconger, this does not seem to work in splunk version 7.1.4. Any idea why? Thank you!&lt;/P&gt;</description>
    <pubDate>Tue, 18 Jun 2019 02:28:52 GMT</pubDate>
    <dc:creator>mrccasi</dc:creator>
    <dc:date>2019-06-18T02:28:52Z</dc:date>
    <item>
      <title>how can i change type of inputText</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/how-can-i-change-type-of-inputText/m-p/244014#M45115</link>
      <description>&lt;P&gt;hi,&lt;/P&gt;

&lt;P&gt;i try to change the type of an inputtext : from text to number&lt;/P&gt;

&lt;P&gt;see an exemple &lt;A href="http://jsfiddle.net/NyxCu/3/"&gt;here&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;thx&lt;/P&gt;</description>
      <pubDate>Wed, 24 Aug 2016 15:06:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/how-can-i-change-type-of-inputText/m-p/244014#M45115</guid>
      <dc:creator>sfatnass</dc:creator>
      <dc:date>2016-08-24T15:06:20Z</dc:date>
    </item>
    <item>
      <title>Re: how can i change type of inputText</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/how-can-i-change-type-of-inputText/m-p/244015#M45116</link>
      <description>&lt;P&gt;There are 2 ways you can do this:&lt;/P&gt;

&lt;P&gt;1 - convert your form to HTML and set the input type to number.&lt;BR /&gt;
2 - keeping the form as SimpleXML, you can change the input type to number with jQuery.  Here's how:&lt;/P&gt;

&lt;P&gt;Set the id of your input field (this will actually just be a prefix to the rendered HTML, but we can take care of that in the Javascript).&lt;BR /&gt;
Also, notice that I set a reference to a Javascript file named "set_numbers.js" in the form tag.  This file should live in $SPLUNK_HOME/etc/apps/YOUR APP/appserver/static&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;form script="set_numbers.js"&amp;gt;
  &amp;lt;label&amp;gt;TestNumber&amp;lt;/label&amp;gt;
  &amp;lt;fieldset submitButton="false"&amp;gt;
    &amp;lt;input type="text" token="field1" id="my_field"&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;Next, we use some jQuery to change the type of the input to number.  This is done in the set_numbers.js file like so:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;require(["jquery", "splunkjs/mvc/simplexml/ready!"], function($) {
    $("[id^=my_field]").attr('type','number')
});
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Notice that I used [id^=my_field] for the jQuery selector.  This tells jQuery to look for elements that start with my_field.  The reason for this is the final rendered field will have an id something like "my_field_9999-input".  This way, we can look for a certain prefix in case you want multiple fields to be numeric.&lt;/P&gt;

&lt;P&gt;Here is a screenshot to show the result.&lt;/P&gt;

&lt;P&gt;&lt;IMG src="https://community.splunk.com/storage/temp/156247-screen-shot-2016-08-24-at-42926-pm.png" alt="alt text" /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 10:43:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/how-can-i-change-type-of-inputText/m-p/244015#M45116</guid>
      <dc:creator>jconger</dc:creator>
      <dc:date>2020-09-29T10:43:45Z</dc:date>
    </item>
    <item>
      <title>Re: how can i change type of inputText</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/how-can-i-change-type-of-inputText/m-p/244016#M45117</link>
      <description>&lt;P&gt;it work well thx but&lt;BR /&gt;
what about underscore and mvc ?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; require(["underscore", "jquery", "splunkjs/mvc", "splunkjs/mvc/simplexml/ready!"], function(_, $, mvc) {
     $("[id^=my_field]").attr('type','number')
 });
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Aug 2016 08:30:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/how-can-i-change-type-of-inputText/m-p/244016#M45117</guid>
      <dc:creator>sfatnass</dc:creator>
      <dc:date>2016-08-25T08:30:26Z</dc:date>
    </item>
    <item>
      <title>Re: how can i change type of inputText</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/how-can-i-change-type-of-inputText/m-p/244017#M45118</link>
      <description>&lt;P&gt;For this example, we do not need underscore or mvc. &lt;/P&gt;</description>
      <pubDate>Thu, 25 Aug 2016 14:55:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/how-can-i-change-type-of-inputText/m-p/244017#M45118</guid>
      <dc:creator>jconger</dc:creator>
      <dc:date>2016-08-25T14:55:40Z</dc:date>
    </item>
    <item>
      <title>Re: how can i change type of inputText</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/how-can-i-change-type-of-inputText/m-p/244018#M45119</link>
      <description>&lt;P&gt;Hi @jconger, this does not seem to work in splunk version 7.1.4. Any idea why? Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jun 2019 02:28:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/how-can-i-change-type-of-inputText/m-p/244018#M45119</guid>
      <dc:creator>mrccasi</dc:creator>
      <dc:date>2019-06-18T02:28:52Z</dc:date>
    </item>
    <item>
      <title>Re: how can i change type of inputText</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/how-can-i-change-type-of-inputText/m-p/244019#M45120</link>
      <description>&lt;P&gt;Here is a snippet that currently works:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;require(["jquery", "splunkjs/mvc/simplexml/ready!"], function($) {

    $("[id^=numbers_only]")
        .find("input")
        .attr('type','number')
});
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 18 Jun 2019 02:58:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/how-can-i-change-type-of-inputText/m-p/244019#M45120</guid>
      <dc:creator>jconger</dc:creator>
      <dc:date>2019-06-18T02:58:53Z</dc:date>
    </item>
    <item>
      <title>Re: how can i change type of inputText</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/how-can-i-change-type-of-inputText/m-p/244020#M45121</link>
      <description>&lt;P&gt;wow it worked &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Thank you for the fast reply!&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jun 2019 03:05:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/how-can-i-change-type-of-inputText/m-p/244020#M45121</guid>
      <dc:creator>mrccasi</dc:creator>
      <dc:date>2019-06-18T03:05:18Z</dc:date>
    </item>
  </channel>
</rss>

