Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

242
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda