How do I change the value of a select box field of a certain entry through the front-end? So I'm having this entry (a product) that contains a selectbox field with two values:


Reserved
Available


By default this field is set to 'Available', but when the user lands on a certain page (a thank you page after "ordering" this product with the entry id as a querystring in the URL), I'd like to change the value of that selectbox to 'Reserved'.

Anyone can put me in the right direction on this one?

Thanks in advance!
Twig
You can check for certain URL parameters via
{% set param = craft.app.getRequest().getParam('id') %}
{% if param is not null %}
    {% set entry = craft.app.getElements().getElementById(param) %}
    {# insert your new field value! not the label, the value/handle
    {% do entry.setFieldValue('fieldHandle', 'Reserved') %}
    {% do craft.app.getElements().saveElement(entry) %}
{% endif %}

However I would not recommend doing this in Twig
PHP
You can see how to use Template Variables and create your boilerplate at pluginfactory.io
{% do craft.myAwesomePlugin.saveEntry(entry, {fieldHandle: 'yourValue'}) %}

And your function could be
public function saveEntry($entry, $attributes = []){
    $entry-&gt;getContent()-&gt;setAttributes($attributes);
    craft()-&gt;entries-&gt;saveEntry($entry);
}

That's just a &quot;quick&quot; version, I suggest you to take a look at EntriesController to see how Craft handles it in detail