# Auto submit with JS Dashboard

**URL:** <https://discourse.nodered.org/t/auto-submit-with-js-dashboard/14720>\
**Category:** Dashboard\
**Created:** [23 August 2019 16:28 UTC](https://discourse.nodered.org/t/auto-submit-with-js-dashboard/14720 "2019-08-23T16:28:42Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![builderbob](https://avatars.discourse-cdn.com/v4/letter/b/df705f/32.png) [@builderbob](https://discourse.nodered.org/u/builderbob)\
**Post date:** [23 August 2019 16:28 UTC](https://discourse.nodered.org/t/auto-submit-with-js-dashboard/14720/1 "2019-08-23T16:28:42Z")

</div>

Hello every one,

I am currently trying to autosubmit a form node composed of a "Number" field.  
This number field is auto-completed by a Javascript code added with a template node.

This part is correctly working :

```auto
    document.getElementsByTagName('input')[0].value='1234';

```

But when I try to click on the submit button (manually or with a JS call to submit() on the form object), the interface does not detect the value 1234 and act as if the numeric field is empty.  
I have to select the input field, add a random character, delete it and submit the form.

Can you help me to understand what's wrong ?

My idea is to submit the form with :

```auto
document.getElementsByTagName('form')[0].submit();

```

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [23 August 2019 17:13 UTC](https://discourse.nodered.org/t/auto-submit-with-js-dashboard/14720/2 "2019-08-23T17:13:36Z")

</div>

If via js. Why not just bypass the form and send it direct. (Or send to both at same time so ui shows the value)

---

<div class="post-metadata">

**Author:** ![builderbob](https://avatars.discourse-cdn.com/v4/letter/b/df705f/32.png) [@builderbob](https://discourse.nodered.org/u/builderbob)\
**Post date:** [23 August 2019 19:57 UTC](https://discourse.nodered.org/t/auto-submit-with-js-dashboard/14720/3 "2019-08-23T19:57:15Z")

</div>

The value "1234" is extracted from a NFC tag read by the user phone.  
The desired steps are the following :

1. The user open the form
2. The user touch the NFC tag with his phone
3. The javascript fill in the text field with the extrated data
4. The javascript auto-submit the form \<= this is where I am stuck whether manually or via JS.

Not sure if I can do it another way.

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [23 August 2019 20:00 UTC](https://discourse.nodered.org/t/auto-submit-with-js-dashboard/14720/4 "2019-08-23T20:00:47Z")

</div>

You could ask @DSongra11_forum.com who would appear to be working on the same exercise

[How can I convert char code numbers to string characters?](https://discourse.nodered.org/t/how-can-i-convert-char-code-numbers-to-string-characters/14610)

---

<div class="post-metadata">

**Author:** ![builderbob](https://avatars.discourse-cdn.com/v4/letter/b/df705f/32.png) [@builderbob](https://discourse.nodered.org/u/builderbob)\
**Post date:** [23 August 2019 20:47 UTC](https://discourse.nodered.org/t/auto-submit-with-js-dashboard/14720/5 "2019-08-23T20:47:32Z")

</div>

My problem is not related to NFC but to JS.  
To explain correctly my problem, I have made this minimalist export to reproduce my bug.

You can note that if you click on the submit button without modifying the value '1234', nothing happen.  
If you edit '1234' so now you can submit the form.

```auto
[{"id":"88656b6b.5f55","type":"ui_form","z":"54850893.0eb13","name":"","label":"","group":"1413a40b.e065d4","order":0,"width":0,"height":0,"options":[{"label":"Number","value":"number","type":"number","required":true}],"formValue":{"number":""},"payload":"","submit":"submit","cancel":"cancel","topic":"","x":160,"y":260,"wires":[[]]},{"id":"85a50092.0d9de","type":"ui_template","z":"54850893.0eb13","group":"1413a40b.e065d4","name":"","order":0,"width":0,"height":0,"format":"<div ng-bind-html=\"msg.payload\"></div>\n<script>\n (function() {\n document.getElementsByTagName('input')[0].value='1234';\n })();\n</script>","storeOutMessages":true,"fwdInMessages":true,"templateScope":"local","x":160,"y":220,"wires":[[]]},{"id":"1413a40b.e065d4","type":"ui_group","z":"","name":"Default","tab":"2d8b3473.faf9b4","disp":true,"width":"6","collapse":false},{"id":"2d8b3473.faf9b4","type":"ui_tab","z":"","name":"Home","icon":"dashboard"}]

```

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [23 August 2019 21:53 UTC](https://discourse.nodered.org/t/auto-submit-with-js-dashboard/14720/6 "2019-08-23T21:53:06Z")

</div>

Ui nodes only send new values, they don't respond to the same value repeated. You should clear down the input after you have handled the reading.

---

<div class="post-metadata">

**Author:** ![builderbob](https://avatars.discourse-cdn.com/v4/letter/b/df705f/32.png) [@builderbob](https://discourse.nodered.org/u/builderbob)\
**Post date:** [23 August 2019 22:16 UTC](https://discourse.nodered.org/t/auto-submit-with-js-dashboard/14720/7 "2019-08-23T22:16:31Z")

</div>

What do you mean by "clear down the input after you have handled the reading" ?  
As shown in my example, I am not even able to submit the first value I defined with .value='1234'.

---

<div class="post-metadata">

**Author:** ![DSongra11\_forum.com](https://avatars.discourse-cdn.com/v4/letter/d/f04885/32.png) [@DSongra11\_forum.com](https://discourse.nodered.org/u/DSongra11_forum.com)\
**Post date:** [25 August 2019 12:44 UTC](https://discourse.nodered.org/t/auto-submit-with-js-dashboard/14720/8 "2019-08-25T12:44:05Z")

</div>

Hi

If you are receiving the same value from the device then it will not update, it will update only change or different value, when you read different NFC device or information then it will update. Same thing happened with me, then i used another tag with different information store in tag.
