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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:36:59+00:00 2026-06-13T02:36:59+00:00

when I use the code below it outputs nothing to the screen. I have

  • 0

when I use the code below it outputs nothing to the screen.

I have global array called tasks[] and this is the function I am trying to run:

function addTask() {
'use strict';

var task = document.getElementById('task');
var outputTask = document.getElementById('taskOutput');
var outputList = document.getElementById('outputList');

var taskMessage = '';

if (task.value) {
    tasks[tasks.length] = task;
    taskMessage = 'You have ' + tasks.length + ' task(s) in your to-do list.';

    if(output.textContent !== undefined) {
        outputTask.textContent = taskMessage;   
    } else {
        outputTask.innerText = taskMessage;
    }


    for (var i = 0, count = tasks.length; i <= count; i++) {
        var listItem = document.createElement('h3');
        var textNode = document.createTextNode(tasks[i]);
        listItem.appendChild(textNode);
        outputList.appendChild(listItem);
    }

}// End task.value IF.
return false;
}// end addTask() function

Here’s the HTML that the javascript is accessing. When I enter a value into the task input field and press submit, I am expecting output to the screen inside the outputList div as H3’s.

    <form id="theForm" name="theForm" />
<fieldset>
<legend>Enter the starting and ending dates of the task</legend>
<label for="start">Start</label>
<input type="text" name="start" id="start" placeholder="MM/DD/YYYY or Today" required />

<label for="end">End</label>
<input type="text" name="end" id="end" placeholder="MM/DD/YYYY" required />
</fieldset>
<fieldset><legend>Enter a Task For This Time Period</legend>
<div>
<label for="task">Task</label>
<input type="text" name="task" id="task" required />
</div>
</fieldset>
<input type="submit" value="Add It!" id="submit" />
</form>
</div>

<div id="output"></div>
<div id="taskOutput"></div>
<div id="outputList"></div>
  • 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-13T02:37:01+00:00Added an answer on June 13, 2026 at 2:37 am

    That’s because you are looping beyond the last item in the array.

    Change this:

    for (var i = 0, count = tasks.length; i <= count; i++) {
    

    to:

    for (var i = 0, count = tasks.length; i < count; i++) {
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use this code below to hide stream url of songs for my wordpress
I use below code to show folder list in AlertDialog: ListDialog = new AlertDialog.Builder(MyActivity.this);
I am using zend. When i use below code, <?= $this->headLink() ->appendStylesheet(BASE_URL . 'css/css.css');
I am trying to use the code below to convert an integer in ax
Can you tell me why this isn't working? The code below outputs student1 &
i use the code below to open a new window when a user drops
As a PHP developer, I always use the code below whenever I want to
I use below code to post an url to facebook page as a admin
I use below code to update listview. setListAdapter(MyAdapter); MyAdapter.notifyDataSetChanged(); getListView().setEmptyView(empty); But each time update,
i use below code - Just try again. - to prevent deadlock. it seems

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.