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 8835141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:11:31+00:00 2026-06-14T09:11:31+00:00

I have what I think should be a simple function that is returning: TypeError:

  • 0

I have what I think should be a simple function that is returning:

TypeError: ele("XYZ") is null

and is not returning the proper value. In my case, element XYZ is called AgeCount. Here is my script:

function countAgesSelected(){
    var agesSelectedCount = 0;
    if (document.myform.a4049.checked==true) {
         agesSelectedCount++;
    }
    if (document.myform.a5064.checked==true) {
         agesSelectedCount++;
    }
    if (document.myform.a65plus.checked==true) {
         agesSelectedCount++;
    }
    ele('AgeCount').value = agesSelectedCount;
}

Browser throws the error on that last line.

Here is relevant HTML:

<input name="4049" type="checkbox" value="4049" id="a4049" starweb_type="Checkbox/Radio Button" checked="checked" onclick="countAgesSelected()" />40-49
<input name="5064" type="checkbox" value="5064" id="a5064" starweb_type="Checkbox/Radio Button" checked="checked" onclick="countAgesSelected()" />50-64
<input name="65plus" type="checkbox" value="65plus" id="a65plus" starweb_type="Checkbox/Radio Button" checked="checked" onclick="countAgesSelected()" />65+
<input type="hidden" value="0" name="AgeCount" />

I am hoping that I just have a simple syntax error. Any help is greatly appreciated!

  • 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-06-14T09:11:32+00:00Added an answer on June 14, 2026 at 9:11 am

    Update

    Mixed up getElementsByName and getElementsByTagName, code is now updated.

    Where is the ele function coming from?

    Use document.getElementsByName("AgeCount")[0] instead of the ele-function or create the ele-function like this:

    function ele(element)
    {
        return document.getElementsByName(element)[0];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have what I think should be a fairly simple mapping issue, but not
I have this really simple c++ function I wrote myself. It should just strip
I have recently been stuck on what I think should be a fairly simple
I think this should be simple. Say I've got the following jQuery: $someForm.live('submit', function(event)
I have what I think should be a fairly simple implementation, but I'm running
We have a relatively simple assignment that I understand in theory but I think
I'm working on UVa #112 Tree Summing . I have what I think should
I have some code which I think should compile, but doesn't: import java.io.InputStream; import
Dear all,Now i have this question in my java program,I think it should be
I think I may have used a repeater when I should have used something

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.