Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6986217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:46:50+00:00 2026-05-27T18:46:50+00:00

i would like someone with experience in JavaScript to please look through this script

  • 0

i would like someone with experience in JavaScript to please look through this script and tell me what i’m doing wrong, the application of this script can be seen at jsfiddle.
The first script showAge() is supposed to get the age from the Date of Birth, and then populate the txt field “age” with the result. the second script is supposed to then parseInt the “age” field and check if the result matches any of the criteria (shown in the if..else statements) and then populate two fields (rsltf and rsltq) with points based on the if..else statements. but right now it just outputs 10 and 16 (the first values of the two if..else if statements) regardless of the age. i really cant figure it out :/

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Quebec and Federal Immigration Points Calculator</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
<script type="text/javascript"> 
function showAge(){ 
var d =document.getElementById('dob').value.split('/'); 
var today = new Date(); 
var bday = new Date(d[2],d[1],d[0]);
var age = today.getFullYear() - bday.getFullYear();  
if(today.getMonth() < bday.getMonth() || (today.getMonth() == bday.getMonth() && today.getDate() < bday.getDate()))  
{
     t = age--;  
}
else {
t = age
}
form.age.value = t; 
} 
</script> 
<script type="text/javascript">
function compute(form)
{
var a = parseInt(form.age.value, 10) || 0; 
if (21 <= a <= 49){
    f = 10;
}
else if (20 == a == 50){
    f = 8;
}
else if (19 == a == 51){
    f = 6;
}
else if (18 == a == 52){
    f = 4;
}
else if (17 == a == 53){
    f = 2;
}
else if (17 > a > 53){
    f = 0;
}
form.rsltf.value = f;
if (18 <= a <= 35){
    q = 16;
}
else if (a == 36){
    q = 14;
}
else if (a == 37){
    q = 12;
}
else if (a == 38){
    q = 10;
}
else if (a == 39){
    q = 8;
}
else if (a == 40){
    q = 6;
}
else if (a == 41){
    q = 4;
}
else if (a == 42){
    q = 2;
}
else if (18 > a > 43){
    q = 0;
}
form.rsltq.value = q;   
}
</script>
</head>
<body>
<form name="form">
<p>Your Date of Birth (format:<strong>dd/mm/yyyy</strong>)</p><br />
<input onBlur="compute(this.form)" onchange="showAge()" name="dob" id="dob" />
<p>Your Age</p><input name="age" type="text" style="font-size: 15px" value="" size="7" readonly>
<h1>Your education</h1>

<INPUT NAME="calc" VALUE="Calculate" TYPE="button" onClick="compute(this.form)"><br />
<input name="rsltf" type="text" style="font-size: 50px" value="" size="20" readonly /><br />
<input name="rsltq" type="text" style="font-size: 50px" value="" size="20" readonly />
</form>
</body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T18:46:51+00:00Added an answer on May 27, 2026 at 6:46 pm

    This code will not work at all:

    function compute(form)
    {
    var a = parseInt(form.age.value, 10) || 0; 
    if (21 <= a <= 49){
        f = 10;
    }
    else if (20 == a == 50){
        f = 8;
    }
    else if (19 == a == 51){
        f = 6;
    }
    else if (18 == a == 52){
        f = 4;
    }
    else if (17 == a == 53){
        f = 2;
    }
    else if (17 > a > 53){
        f = 0;
    }
    

    JavaScript will interpret this like so:

    21 <= a <= 49
    (21 <= a) <= 49
    (1 or 0) <= 49
    true
    

    You need to be verbose:

    (21 <= a) && (a <= 49)
    

    What about this code:

    17 == a == 53
    

    What is it supposed to do?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to access a MySQL database using PHP. Can someone please explain
I would like someone experience with kannel to enlighten me please. I currently run
I would like someone to explain me what _forward is exactly doing, I cannot
When someone installs this plugin, I would like a file to be copied into
This is clearly not appears like it wouldn't be a best practice. Can someone
For my school project, I would like to build a gui that someone else
I would like to find out if someone (and maybe someone on StackOverflow works
I have a project that can be built via makefile, and I would like
I would like to mix MP3 files with Delphi 2010. Is this possible? Does
Using JavaScript I would like to check if a given URL matches a list

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.