<?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 implement JQuery in an HTML dashboard to add a &amp;quot;Clear&amp;quot; button to clear two input fields? in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-implement-JQuery-in-an-HTML-dashboard-to-add-a-quot-Clear/m-p/135268#M8073</link>
    <description>&lt;P&gt;I do have a part of the code for the inputs:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;        var input1 = new TextInput({
            "id": "input1",
            "default": "\"\"",
            "searchWhenChanged": false,
            "value": "$form.userid$",
            "el": $('#input1')
        }, {tokens: true}).render();

        input1.on("change", function(newValue) {
            FormUtils.handleValueChange(input1);
        });


        var input2 = new TextInput({
            "id": "input2",
            "default": "\"\"",
            "searchWhenChanged": false,
            "value": "$form.racf$",
            "el": $('#input2')
        }, {tokens: true}).render();

        input2.on("change", function(newValue) {
            FormUtils.handleValueChange(input2);
        });
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And I have referenced the same IDs in the clear_fields() function (as in the original post).  I tired the below code as well:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;$('input1').val('');
                     $('input2').val('');
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Neither way it works.  &lt;/P&gt;</description>
    <pubDate>Mon, 27 Jul 2015 13:52:40 GMT</pubDate>
    <dc:creator>pashernx</dc:creator>
    <dc:date>2015-07-27T13:52:40Z</dc:date>
    <item>
      <title>How to implement JQuery in an HTML dashboard to add a "Clear" button to clear two input fields?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-implement-JQuery-in-an-HTML-dashboard-to-add-a-quot-Clear/m-p/135265#M8070</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have a simple XML dashboard and converted it to HTML.  I have added a clear button to clear two input fields, but the clear option doesn't seem to work.  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...
&amp;lt;div class="input input-text" id="input1"&amp;gt;
            &amp;lt;label&amp;gt;First Name&amp;lt;/label&amp;gt;
&amp;lt;/div&amp;gt;
&amp;lt;div class="input input-text" id="input2"&amp;gt;
            &amp;lt;label&amp;gt;Last Name&amp;lt;/label&amp;gt;
&amp;lt;/div&amp;gt;
...
...
...
&amp;lt;div class="form-submit" id="clrb"&amp;gt;
            &amp;lt;button class="btn btn-default" id="clear_btn"&amp;gt;Clear&amp;lt;/button&amp;gt;
&amp;lt;/div&amp;gt;
...
...
...
function clear_fields() {
            $('#input1').val('');
                    $('#input2').val('');
}
...
...
...
$('#clear_btn').on('click', function () {
            clear_fields())
...
...
...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Am I missing anything here?  Is this possible with javascript?&lt;/P&gt;

&lt;P&gt;Regards,&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jul 2015 18:27:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-implement-JQuery-in-an-HTML-dashboard-to-add-a-quot-Clear/m-p/135265#M8070</guid>
      <dc:creator>pashernx</dc:creator>
      <dc:date>2015-07-22T18:27:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to implement JQuery in an HTML dashboard to add a "Clear" button to clear two input fields?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-implement-JQuery-in-an-HTML-dashboard-to-add-a-quot-Clear/m-p/135266#M8071</link>
      <description>&lt;P&gt;That's not going to work, unless you have some code you aren't showing. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;$('#element').val('');
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Does not work. For anything. You need to drill down until you see the Javascript section with the instantiation of the Inputs. Note the variables they are called (might be &lt;CODE&gt;input1&lt;/CODE&gt; or &lt;CODE&gt;element1&lt;/CODE&gt;). Then you reference them in the click function to clear the data. &lt;/P&gt;

&lt;P&gt;Pastebin the Sourcecode (and put the link here) and we can review the code and make a better suggestion.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jul 2015 16:49:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-implement-JQuery-in-an-HTML-dashboard-to-add-a-quot-Clear/m-p/135266#M8071</guid>
      <dc:creator>alacercogitatus</dc:creator>
      <dc:date>2015-07-23T16:49:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to implement JQuery in an HTML dashboard to add a "Clear" button to clear two input fields?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-implement-JQuery-in-an-HTML-dashboard-to-add-a-quot-Clear/m-p/135267#M8072</link>
      <description>&lt;P&gt;You will need to call the SplunkJS component function. You can do this by using mvc.Components.getInstance() to get the SplunkJS instance and then you can call that version of val(). For example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;mvc.Components.getInstance('description-input').val('');
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;To find the ID of the input, look through the HTML for the input and see what the ID is. It should look something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;var input1 = new TextInput({
     "id": "description-input",
     "searchWhenChanged": false,
     "el": $('#description-input', this.$el)
}, {tokens: true}).render();
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Jul 2015 17:10:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-implement-JQuery-in-an-HTML-dashboard-to-add-a-quot-Clear/m-p/135267#M8072</guid>
      <dc:creator>LukeMurphey</dc:creator>
      <dc:date>2015-07-23T17:10:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to implement JQuery in an HTML dashboard to add a "Clear" button to clear two input fields?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-implement-JQuery-in-an-HTML-dashboard-to-add-a-quot-Clear/m-p/135268#M8073</link>
      <description>&lt;P&gt;I do have a part of the code for the inputs:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;        var input1 = new TextInput({
            "id": "input1",
            "default": "\"\"",
            "searchWhenChanged": false,
            "value": "$form.userid$",
            "el": $('#input1')
        }, {tokens: true}).render();

        input1.on("change", function(newValue) {
            FormUtils.handleValueChange(input1);
        });


        var input2 = new TextInput({
            "id": "input2",
            "default": "\"\"",
            "searchWhenChanged": false,
            "value": "$form.racf$",
            "el": $('#input2')
        }, {tokens: true}).render();

        input2.on("change", function(newValue) {
            FormUtils.handleValueChange(input2);
        });
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And I have referenced the same IDs in the clear_fields() function (as in the original post).  I tired the below code as well:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;$('input1').val('');
                     $('input2').val('');
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Neither way it works.  &lt;/P&gt;</description>
      <pubDate>Mon, 27 Jul 2015 13:52:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-implement-JQuery-in-an-HTML-dashboard-to-add-a-quot-Clear/m-p/135268#M8073</guid>
      <dc:creator>pashernx</dc:creator>
      <dc:date>2015-07-27T13:52:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to implement JQuery in an HTML dashboard to add a "Clear" button to clear two input fields?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-implement-JQuery-in-an-HTML-dashboard-to-add-a-quot-Clear/m-p/135269#M8074</link>
      <description>&lt;P&gt;You need to use a reference to the SplunkJS component, not a jQuery reference to the input element directly.&lt;/P&gt;

&lt;P&gt;Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;mvc.Components.getInstance('input1').val('');
mvc.Components.getInstance('input2').val('');
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 27 Jul 2015 16:59:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-implement-JQuery-in-an-HTML-dashboard-to-add-a-quot-Clear/m-p/135269#M8074</guid>
      <dc:creator>LukeMurphey</dc:creator>
      <dc:date>2015-07-27T16:59:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to implement JQuery in an HTML dashboard to add a "Clear" button to clear two input fields?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-implement-JQuery-in-an-HTML-dashboard-to-add-a-quot-Clear/m-p/135270#M8075</link>
      <description>&lt;P&gt;It worked.  Thanks!! &lt;/P&gt;</description>
      <pubDate>Mon, 27 Jul 2015 17:44:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-implement-JQuery-in-an-HTML-dashboard-to-add-a-quot-Clear/m-p/135270#M8075</guid>
      <dc:creator>pashernx</dc:creator>
      <dc:date>2015-07-27T17:44:45Z</dc:date>
    </item>
  </channel>
</rss>

