title: Symfony 4 - Is there a way to use a script function to set a twig variable?
body: <p>I would like to set a prompt box fromjavascript and pass the text entered to my twig attribute msg.</p>
  
  <p>But I don't know how I can pass from my script to my twig.</p>
  
  <p>There is my code for now.</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      function PromptMessage() {
          var saisie = prompt("Saisissez votre texte :", "Texte par défaut");
          console.log(saisie);
  
      }
  &lt;/script&gt;
  
  {# It works with an hardcode value in twig #}
  {% set msg = 'egaezrf' %}
  
      &lt;button type="button" class="btn btn-success" onclick="window.location.href = '{{ path('email_index', {'iduser': onlineorder.iduser.iduser, 'msg': msg}) }}';"&gt;Send Email&lt;/button&gt;
  </code></pre>