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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:09:30+00:00 2026-05-25T16:09:30+00:00

I can’t manage to make the line in the code with all the asterisks

  • 0

I can’t manage to make the line in the code with all the asterisks to work. Can anyone help? The function works fine, it is just the document.write('This will not print'); that doesn’t actually work. What is the problem?

//UPDATE//

First of all, thanks for the quick replies. Now I will post the full code.
As you can see the variable ii is declared at the body.

FULL CODE

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript">
<!--
function runThis() {
var fruta01 = document.getElementById('fruta').value;
var color01 = document.getElementById('color').value;
var problemo = true;
    for (newCount = 0; newCount<=ii; newCount++){
            if (storeArray[newCount].match(fruta01) && storeArray[newCount].match(color01)){
            document.write(storeArray[newCount]+'<br/>');
            problemo = false;
            };
    };
document.write('This doesnt print')
};

//-->
</script>
</head>

<body>
<script type="text/javascript">
<!--

//Matriz total
var storeArray = new Array ()

//Numero de objetos
var ii = 0;

//Color de los objetos
var colorCounter = 0
var color = new Array ()
color[0] = 'verde';
color[1] = 'amarillo';

//tipo de objetos
var objectCounter = 0
var object = new Array ()
object[0] = 'limones';
object[1] = 'platanos';
object[2] = 'manzanas';



for (ii; ii<8; ii++) {
storeArray[ii] = 'Tengo ' + ii + ' ' + object[objectCounter] +' de color ' + color[colorCounter];

        if (objectCounter != 2) {
        ++objectCounter
        }else{
        objectCounter = 0   
        }
        if (colorCounter != 1) {
        ++colorCounter
        }else{
        colorCounter = 0    
        }
} 

//print array so that you may see what you can choose...
for(var i=0;i<storeArray.length;i++){
document.write(storeArray[i]+"<br>");
}

//-->
</script>

<form>
Que fruta buscas? <input type="text" size="10" id='fruta'/><br />
De que color? <input type="text" size="10" id='color'/><br />
<input type="submit" value="Submit!" onclick="runThis()"/>
</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-25T16:09:31+00:00Added an answer on May 25, 2026 at 4:09 pm

    EDIT

    The problem is in your for loop

    for (newCount = 0; newCount <= ii; newCount++ )
    

    Should be

    for (newCount = 0; newCount < ii; newCount++ )
    

    You don’t have to put a semicolon after function, and ‘if’ and ‘for’ loops.

    Here is a better version of your code

    function runThis () {
        var fruta01 = document.getElementById('fruta').value;
        var color01 = document.getElementById('color').value;
        var problemo = true;
    
        for (newCount = 0; newCount <= ii; newCount++ )
        {
            if (storeArray[newCount].match(fruta01) && storeArray[newCount].match(color01) )
            {
                document.write(storeArray[newCount]+'<br/>');
                problemo = false;
            }
        }
    
        document.write('This will not print'); //**************************
    }
    

    Just use console.log() or a simple alert if you want to check just that.

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

Sidebar

Related Questions

Can anyone help me trying to find out why this doesn't work. The brushes
Can anyone (maybe an XSL-fan?) help me find any advantages with handling presentation of
Can i get the source code for a WAMP stack installer somewhere? Any help
can anyone tell me why this doesn't work? db = openOrCreateDatabase(database.db, SQLiteDatabase.CREATE_IF_NECESSARY, null); db.setLocale(Locale.getDefault());
Can't work out a way to make an array of buttons in android. This
Can anyone help me with an excel formula that groups related rows and creates
Can we close all known/unknown connections to database with the code? I'm using Access
Can anyone can confirm the best idea for storing jquery code, initially i was
Can anyone tell me how I can display a status message like 12 seconds
Can anyone recommend a good library for generating an audio file, such as mp3,

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.