# How to get text input value

**URL:** <https://discourse.nodered.org/t/how-to-get-text-input-value/6386>\
**Category:** Dashboard\
**Created:** [4 January 2019 13:44 UTC](https://discourse.nodered.org/t/how-to-get-text-input-value/6386 "2019-01-04T13:44:28Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![lucianv](https://avatars.discourse-cdn.com/v4/letter/l/cab0a1/32.png) [@lucianv](https://discourse.nodered.org/u/lucianv)\
**Post date:** [4 January 2019 13:44 UTC](https://discourse.nodered.org/t/how-to-get-text-input-value/6386/1 "2019-01-04T13:44:28Z")

</div>

Hi all,

I have a flow where I have a text input. I do a select from a db and fill the data in that text input. Then I want to change that text and save it (means do another query and update it in db).  
I managed to put in text input the text i read from db but I am not able to get it's value when i press save...  
Any help on that?  
Thanks

`[{"id":"aa98e43.bcd4418","type":"tab","label":"Flow 5","disabled":false,"info":""},{"id":"407e1f98.f54d8","type":"function","z":"aa98e43.bcd4418","name":"query ins logo","func":"msg.topic = \"SELECT * FROM ins_logo\"\n\nreturn msg;","outputs":1,"noerr":0,"x":374,"y":215,"wires":[["59d7c426.a7093c"]]},{"id":"59d7c426.a7093c","type":"mysql","z":"aa98e43.bcd4418","mydb":"c1295981.fb5958","name":"usvstdt","x":558,"y":215,"wires":[["dacea586.f41748"]]},{"id":"dacea586.f41748","type":"change","z":"aa98e43.bcd4418","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload[0].name","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":760.5,"y":215,"wires":[["b51e306c.5902b"]]},{"id":"b51e306c.5902b","type":"ui_text_input","z":"aa98e43.bcd4418","name":"name","label":"Name","tooltip":"","group":"3a69d2ce.2e17be","order":2,"width":"6","height":"1","passthru":false,"mode":"text","delay":300,"topic":"{{msg.payload[0].name}}","x":949.5,"y":213,"wires":[["5993645e.a4326c"]]},{"id":"c2738d5b.83eb5","type":"ui_button","z":"aa98e43.bcd4418","name":"","group":"3a69d2ce.2e17be","order":17,"width":"4","height":"1","passthru":false,"label":"Save","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","x":358.5,"y":365,"wires":[["5993645e.a4326c"]]},{"id":"5993645e.a4326c","type":"change","z":"aa98e43.bcd4418","name":"2","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.name","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":640.5,"y":371,"wires":[["73e2bdd0.904fa4"]]},{"id":"73e2bdd0.904fa4","type":"debug","z":"aa98e43.bcd4418","name":"","active":true,"tosidebar":true,"console":true,"tostatus":false,"complete":"payload","x":874.5,"y":375,"wires":[]},{"id":"c1295981.fb5958","type":"MySQLdatabase","z":"","host":"127.0.0.1","port":"3306","db":"usvstd","tz":""},{"id":"3a69d2ce.2e17be","type":"ui_group","z":"","name":"Inserare Logo","tab":"a8840ceb.2d6c6","order":4,"disp":true,"width":"12","collapse":false},{"id":"a8840ceb.2d6c6","type":"ui_tab","z":"","name":"USV","icon":"dashboard","order":1}]`

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [4 January 2019 15:36 UTC](https://discourse.nodered.org/t/how-to-get-text-input-value/6386/2 "2019-01-04T15:36:19Z")

</div>

Have you gone to the flow's library and searched for 'sql' or 'crud'? and I seem to remember some threads in the last couple months about this.

---

<div class="post-metadata">

**Author:** ![lucianv](https://avatars.discourse-cdn.com/v4/letter/l/cab0a1/32.png) [@lucianv](https://discourse.nodered.org/u/lucianv)\
**Post date:** [4 January 2019 16:00 UTC](https://discourse.nodered.org/t/how-to-get-text-input-value/6386/3 "2019-01-04T16:00:23Z")

</div>

I don t have a problem with sql, i know how to do that. I don t know how to get text from the input text into a variable, this is my issue

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [4 January 2019 16:08 UTC](https://discourse.nodered.org/t/how-to-get-text-input-value/6386/4 "2019-01-04T16:08:34Z")

</div>

So have you looked at the various threds and flows and found none that will help you?

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [4 January 2019 16:26 UTC](https://discourse.nodered.org/t/how-to-get-text-input-value/6386/5 "2019-01-04T16:26:07Z")

</div>

You cannot 'get' its value from the text box.

The approach you should take is to use Flow Context to store the value where you can then retrieve it from anywhere else in your flow.

You can do this by wiring a Change node after the ui\_text node to "set `flow.foo` to `msg.payload`"

Then you can use `flow.foo` else where in your flow (via Change node or Function node) to get its current value.

---

<div class="post-metadata">

**Author:** ![lucianv](https://avatars.discourse-cdn.com/v4/letter/l/cab0a1/32.png) [@lucianv](https://discourse.nodered.org/u/lucianv)\
**Post date:** [5 January 2019 12:56 UTC](https://discourse.nodered.org/t/how-to-get-text-input-value/6386/6 "2019-01-05T12:56:09Z")

</div>

Ok, I simplified the flow to exactly my issue. So the flow is 🙂

`[{"id":"cfc4cf05.25252","type":"tab","label":"Flow 10","disabled":false,"info":""},{"id":"d6c62f69.6a0ab","type":"ui_button","z":"cfc4cf05.25252","name":"","group":"a59b5a47.e196d8","order":32,"width":0,"height":0,"passthru":false,"label":"save","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","x":500,"y":393,"wires":[["1362df8e.d13b3"]]},{"id":"a81e7e43.881dc","type":"ui_text_input","z":"cfc4cf05.25252","name":"","label":"text","tooltip":"","group":"a59b5a47.e196d8","order":31,"width":0,"height":0,"passthru":true,"mode":"text","delay":300,"topic":"text","x":498,"y":308,"wires":[["1362df8e.d13b3","1bf73e07.5b49a2"]]},{"id":"1bf73e07.5b49a2","type":"debug","z":"cfc4cf05.25252","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":880,"y":358,"wires":[]},{"id":"1362df8e.d13b3","type":"function","z":"cfc4cf05.25252","name":"text","func":"var text = msg.payload ;\n\nmsg.payload = text;\n\nreturn msg;","outputs":1,"noerr":0,"x":690,"y":392,"wires":[["1bf73e07.5b49a2"]]},{"id":"a59b5a47.e196d8","type":"ui_group","z":"","name":"Meniu Principal","tab":"a8840ceb.2d6c6","order":1,"disp":false,"width":"12","collapse":false},{"id":"a8840ceb.2d6c6","type":"ui_tab","z":"","name":"USV","icon":"dashboard","order":1}]`

When I type in the text input I get what I type in debug console. That is because " If `msg` arrives on input, pass through to output:" option is checked.  
But when I click save button I get

msg.payload : string[14]

"d6c62f69.6a0ab"

in the debug console. I am just not able to get that text into a variable...

---

<div class="post-metadata">

**Author:** ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)\
**Post date:** [5 January 2019 13:11 UTC](https://discourse.nodered.org/t/how-to-get-text-input-value/6386/7 "2019-01-05T13:11:38Z")

</div>

You need to store textinput in function context and use it when you save.

```auto
[{"id":"f75bd48b.f31218","type":"ui_button","z":"9492aff.e31d05","name":"","group":"39627b16.6f4254","order":32,"width":0,"height":0,"passthru":false,"label":"save","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"save","x":510,"y":400,"wires":[["bd27a3a5.f3c0c"]]},{"id":"c410bd71.4b1e7","type":"ui_text_input","z":"9492aff.e31d05","name":"","label":"text","group":"39627b16.6f4254","order":31,"width":0,"height":0,"passthru":true,"mode":"text","delay":300,"topic":"textinput","x":510,"y":320,"wires":[["bd27a3a5.f3c0c"]]},{"id":"abef5d31.9c6b5","type":"debug","z":"9492aff.e31d05","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":840,"y":320,"wires":[]},{"id":"bd27a3a5.f3c0c","type":"function","z":"9492aff.e31d05","name":"text","func":"var lastinput = context.get(\"lastinput\") || \"\";\n\nif(msg.topic === \"textinput\"){\n lastinput = msg.payload;\n context.set(\"lastinput\",lastinput);\n}\nif(msg.topic === \"save\"){\n msg.payload = lastinput;\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":680,"y":380,"wires":[["abef5d31.9c6b5"]]},{"id":"39627b16.6f4254","type":"ui_group","z":"","name":"Meniu Principal","tab":"8bccc011.1774a","order":1,"disp":false,"width":"12","collapse":false},{"id":"8bccc011.1774a","type":"ui_tab","z":"","name":"USV","icon":"dashboard","order":1}]

```

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [5 January 2019 13:14 UTC](https://discourse.nodered.org/t/how-to-get-text-input-value/6386/8 "2019-01-05T13:14:47Z")

</div>

add a seperate debug node to each of your three nodes - this way when you hoverer an entry in the debug log, it will highlight the node it came from.

Type some text and look at the debug log then press the button and look at the debug log.

What do you see? What does it mean?

---

<div class="post-metadata">

**Author:** ![bubuamu](https://avatars.discourse-cdn.com/v4/letter/b/8c91f0/32.png) [@bubuamu](https://discourse.nodered.org/u/bubuamu)\
**Post date:** [13 June 2019 06:55 UTC](https://discourse.nodered.org/t/how-to-get-text-input-value/6386/9 "2019-06-13T06:55:32Z")

</div>

I have the same problem can anybody tell me how to get textinput or in my case calendar node value without activating/click the node? i want to get the default value on the node when i deploy the flow with out making the node send message to the next node by clicking on it. THAT IS TO SAY when i click only save button and get the textinput value even if it is empty or not.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [13 June 2019 09:40 UTC](https://discourse.nodered.org/t/how-to-get-text-input-value/6386/10 "2019-06-13T09:40:12Z")

</div>

> i want to get the default value on the node when i deploy the flow with out making the node send message to the next node by clicking on it.

No you can not do it with that node. Why not use an inject node - set to send a timestamp - connect to the input of ui\_date\_picker. It will forward that value out of the ui\_date\_picker to the rest of your flow.
