Auto submit with JS Dashboard

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 :

    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 :

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

Thanks in advance.

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)

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.

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?

2 Likes

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.

[{"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"}]

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.

1 Like

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'.

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.