codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  HTML using javaScript help..  elsa at 05:40 on Wednesday, November 07, 2007
 

the question is as follows:

Using JavaScript, write a script that inputs five numbers and determines and outputs HTML text that displays the number of negative numbers, the number of positive numbers, and the number of zeros input.
the code i have written is this:
=========================================
<HTML>
<HEAD>
<TITLE> HW2-QUESTION2</TITLE>
</HEAD>

<SCRIPT LANGUAGE ="JavaScript">

var negative=0,
positive=0,
zeros=0,
number=1,
count;

while (number<=5){
count= window.prompt( "enter a number","0");

if(count=="0")
zeros=zeros+1;

else if(count>0)
positive = positive+1;

else
negative=negative+1;

number= number+1;
}

document.writeln( "<H1>Count Results</H1>");

document.writeln("zeros: " + zeros +"<BR>positive:"
+positive+"<BR>negative:" + negative +);

</SCRIPT>
</HTML>
=========================================

there is something wrong with the code because it is not working..plz help me out..

  Re: HTML using javaScript help..  muneepenee at 11:34 on Friday, November 09, 2007
 

1. all yuzer input is character. Yu gotta konvert tu numbers...
innumber=parseInt(inputchars);
2. Yu need sum wae tu stop ask for the input.
2.1 yu kan put in in a for loop tu duit
5 times.
2.2 or chek if input is null or all blank
tu stop program.

<Added>

oops...yu hav while loop
3. zero is positive.
4. yu left off the "{"...
if(sumthang){
stuff
}

<Added>

5. I rekmend better variabel names:
numloops
numpositiv
numneg
numzero

<Added>

6. if yu run with internet explorer, look down at bottom av skreen next the the start button.
If js see errer in yer kode if put up a "!" there
klik on it tu see wot it thank av yer kode.

<Added>

7. yu kan stop the loop if no input with
if(inputchar == ""){break}








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums
//








Recent Forum Threads
•  Passing Multiple Values from a child window to parent window
•  Re: inserting values from pop up
•  partial string sorting of arrays
•  jumping to a different web page
•  Re: Page Load is getting called twice
•  values from asp to html
•  Re: Write text strings to Serial Port
•  Calcluate Date Difference [Seriouslt a new challenge]
•  source code to generate perl library


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2007