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

88
Views
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 answers
Answer question

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 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!