Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

175
Views
Using a javascript variable in twig form

So I am trying to put a Javascript variable in a twig form. This is where I declare my Javascript variable :


<script>
    function add() {
        var active_date = $('#calendar').evoCalendar('getActiveDate');
        sessionStorage.setItem("myDate", active_date);
     
    }
</script>


    <div class="contact-form">
        <a  href="{{ path('rdv_new') }}" class="btn btn-3" onclick="add()" > Book now! </a>

    </div>

And in another file .html.twig I am calling this variable but I can't find a way to assign it to my twig form like so

 <script>
     var myDate = sessionStorage.getItem("myDate");
     
   
 </script>

   {{ form_widget(form.date, {'value' : myDate}) }}

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!