# How to pass value from form textfield to snippet

**URL:** <https://community.modx.com/t/how-to-pass-value-from-form-textfield-to-snippet/5429>\
**Category:** Development\
**Created:** [June 2, 2022, 10:48am UTC](https://community.modx.com/t/how-to-pass-value-from-form-textfield-to-snippet/5429 "2022-06-02T10:48:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![pakosfakos](https://community.modx.com/letter_avatar_proxy/v4/letter/p/41988e/32.png) [@pakosfakos](https://community.modx.com/u/pakosfakos)\
**Post date:** [June 2, 2022, 10:48am UTC](https://community.modx.com/t/how-to-pass-value-from-form-textfield-to-snippet/5429/1 "2022-06-02T10:48:35Z")

</div>

I created a simple snippet [[!qdb? &MList=‘1’]] who is querying database table and returns the data.  
When i use it directly in my page it returns correct data table. Now i want to add a textfield, in the same html page, probably inside form in order the user to write in the field the value of variable MList and by button submission this value to be passed inside my snippet(instead of ‘1’ in my above example ) and to receive the expected table output. I tried to find something similar without success any help will be appreciated.  
Thanks

---

<div class="post-metadata">

**Author:** ![halftrainedharry](https://community.modx.com/user_avatar/community.modx.com/halftrainedharry/32/1063_2.png) [@halftrainedharry](https://community.modx.com/u/halftrainedharry)\
**Post date:** [June 2, 2022, 11:08am UTC](https://community.modx.com/t/how-to-pass-value-from-form-textfield-to-snippet/5429/2 "2022-06-02T11:08:17Z")

</div>

In your snippet just read the value of the form field from the variables `$_POST`, `$_GET` or `$_REQUEST` (depending on how you set up your form).

Or use an extra like [getReqParam](https://modx.com/extras/package/getreqparam) or [getUrlParam](https://modx.com/extras/package/geturlparam) that do the same.

---

<div class="post-metadata">

**Author:** ![pakosfakos](https://community.modx.com/letter_avatar_proxy/v4/letter/p/41988e/32.png) [@pakosfakos](https://community.modx.com/u/pakosfakos)\
**Post date:** [June 2, 2022, 12:30pm UTC](https://community.modx.com/t/how-to-pass-value-from-form-textfield-to-snippet/5429/3 "2022-06-02T12:30:25Z")

</div>

Thank you for your response, gerReqParam sounds good to me, is there any document who explains how to use it?

---

<div class="post-metadata">

**Author:** ![halftrainedharry](https://community.modx.com/user_avatar/community.modx.com/halftrainedharry/32/1063_2.png) [@halftrainedharry](https://community.modx.com/u/halftrainedharry)\
**Post date:** [June 2, 2022, 12:40pm UTC](https://community.modx.com/t/how-to-pass-value-from-form-textfield-to-snippet/5429/4 "2022-06-02T12:40:49Z")

</div>

I think something like this should work:

```auto
[[!qdb? &MList=`[[!getReqParam? &name=`field_name` &type=`POST`]]` ]]

```

Just look at the code of the snippet. All it does is to read the value from the specified Superglobal.

---

<div class="post-metadata">

**Author:** ![pakosfakos](https://community.modx.com/letter_avatar_proxy/v4/letter/p/41988e/32.png) [@pakosfakos](https://community.modx.com/u/pakosfakos)\
**Post date:** [June 2, 2022, 12:52pm UTC](https://community.modx.com/t/how-to-pass-value-from-form-textfield-to-snippet/5429/5 "2022-06-02T12:52:18Z")

</div>

Thank you very much, this is what i was looking for
