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

89
Vistas
Prefill checkbox via link and preserve form function

I currently have a form i built that is 3 large check boxes, when selected they toggle the continue button below them, https://staging-homecarepulse.kinsta.cloud/demo-select/ this is the link so you can check it out.

Currently im trying to add functionality to the form that when you click a link from another page, it preselects the checkbox depending on the link selected.

I was able to find a script that allows me to setup a link with a hash ( https://staging-homecarepulse.kinsta.cloud/demo-select/#checkbox1 ) but my issue is that I cannot get the continue button to trigger when the form is accessed this way.

here is my code

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<script>
$(document).ready(function(){
  var hash = location.hash;

  if(hash=="#checkbox1"){
    $("#checkbox1").prop("checked", !$("#checkbox1").prop("checked") );  // that toggles the checked state
  }
});
</script>


<script>
$(document).on("change", ".mod-link", function() {
  var arr = []
  $(".mod-link:checked").each(function() {
    arr.push($(this).val());
  })
      if (arr.length > 0) {
      $('#picture').attr('src', '');
    } else {
        $('#picture').attr('src', 'https://staging-homecarepulse.kinsta.cloud/wp-content/uploads/2021/06/greyBTN.jpg');
    } 
  
  var vals = arr.join(",")
  var str = "/demo/?demo_request_type=" + vals;
  var link = arr.length > 0 ? '<a class="dynabtn" href="'+str+'">Continue</a>': '' ;
  
  $('.link-container').html(link);
  
});

</script>

anyone have any idea how i can use links like https://staging-homecarepulse.kinsta.cloud/demo-select/#checkbox1 to trigger that checkbox and still have the continue button toggle on?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Instead of trying to toggle the checked property, fire a click event on your checkbox.

$(document).ready(function() {
  if (location.hash) {
    let $checkbox = $(location.hash);
    if ($checkbox.length) $checkbox.click();
  }
});

Your Continue button will toggle as well.

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