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

250
Views
change <input> value with AlpineJS

I'm making a website and learning AlpineJS. I'm trying to make a custom 'checkbox' (from tailwindcss) to make people agree to the Terms of Service.

<div class="flex-shrink-0">
  <!-- Enabled: "bg-indigo-600", Not Enabled: "bg-gray-200" -->
  <button x-show="!isOpen" @click="isOpen = !isOpen" type="button" role="switch" aria-checked="false">
  <span class="sr-only">Agree to policies</span>
  <!-- Enabled: "translate-x-5", Not Enabled: "translate-x-0" -->
  <span aria-hidden="true"></span>
  </button>
  <button x-show="isOpen" @click="isOpen = !isOpen" type="button" role="switch" aria-checked="false">
  <span class="sr-only">Agree to policies</span>
  <!-- Enabled: "translate-x-5", Not Enabled: "translate-x-0" -->
  <span aria-hidden="true"></span>
  </button>
</div>

Now there's probably already a better way to do this custom checkbox because now I'm replacing the entire checkbox when you click it. So if you have tips for that, please let me know!

With flask I need to get the value of this checkbox. But since it's not a real checkbox, I can't just get the data through the POST request. So I figured I could use a hidden to parse the data with the POST request.

<input type="hidden" name="terms" value="">

I want the value in the to be either 'true' or 'false' so I can do things with that in my code. I can't seem to find a good solution anywhere online but I'm sure the is one. Does anybody have any ideas?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Alpine.js uses the x-model directive to bind variables to input elements. Just put this hidden input element anywhere in your form where isOpen variable is present:

<input type="hidden" name="terms" x-model="isOpen" />
about 4 years ago · Juan Pablo Isaza Report
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!