Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How can I redirect by clicking button two different page based on age?

If 30-41 years >Button > go to a website…….

Otherwish 42-99 years > same button >go to another website.

Here is my code:
https://drive.google.com/file/d/1iqCo2CuvPP5Sm_olIZFoovXBlsiG0H6o/view?usp=sharing

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

JavaScript is there to rescue.

HTML:

<button onclick="navigation()">Click</button>

JavaScript

<script>
function navigation(){
  var age = 40; // Not sure how you detect age
  if (age>=30 && age<=41)
      window.open("http://www.website1.com");
  else if (age>=42 && age<=99)
      window.open("http://www.website2.com");
}
</script>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading