Hi i've been developing this javascript program that prompts the user for a first number then a second number and then displays all numbers between them two. So for eg if a user types in 5 for the first number then 10 for the second it should display it like this, 5, 6, 7, 8, 9, 10 It only displays the first number at the moment and not the second, heres the code. <!-- jsset1_6.html --> <html> <head> <title>jsset1_6.html</title> <style type="text/css"> body { background-color:#000000; color:#FFFFFF; font-size:30; text-align:center; } </style> </head> <body> <script type="text/javascript"> var first, count, stroutput; count = 1; stroutput = ""; document.write("<h1>Jsset1_6 - Positive Integers</h1>"); first = prompt("Enter First Number", ""); second = prompt("Enter Second Number", ""); if (first == null) { stroutput = ("You clicked cancel. No count will be shown."); } else if (first == "") { stroutput = ("First Number must be entered."); } else if (first != parseInt(first)) { stroutput = ("First Number must be a valid whole number"); } else if (second <= first) { stroutput = ("Second number should not be lower than the first"); } else { while (count <= first) { stroutput = stroutput + count + "\n"; count = count + 1; } } alert (stroutput); document.write("<br /><br />"); document.write("<br /><br />"); document.write("<input type='button' name='cmdReload'"); document.write(" value='Do again' onclick='window.location.reload()' />"); </script> </body> </html> Code (markup): Many thanks for any help.
Here is the code that you want: <!-- jsset1_6.html --> <html> <head> <title>jsset1_6.html</title> <style type="text/css"> body { background-color:#000000; color:#FFFFFF; font-size:30; text-align:center; } </style> </head> <body> <script type="text/javascript"> var first, count, stroutput; stroutput = ""; document.write("<h1>Jsset1_6 - Positive Integers</h1>"); first = parseInt(prompt("Enter First Number", "")); second = parseInt(prompt("Enter Second Number", "")); if (first == null) { stroutput = ("You clicked cancel. No count will be shown."); } else if (first == "") { stroutput = ("First Number must be entered."); } else if (first != parseInt(first)) { stroutput = ("First Number must be a valid whole number"); } else if (second <= first) { stroutput = ("Second number should not be lower than the first"); } else { count = first; while (count <= second) { stroutput = stroutput + count + "\n"; count = count + 1; } } alert (stroutput); document.write("<br /><br />"); document.write("<br /><br />"); document.write("<input type='button' name='cmdReload'"); document.write(" value='Do again' onclick='window.location.reload()' />"); </script> </body> </html> Code (JavaScript):