Sofia
03-15-2005, 05:02 PM
Hi
I've entered the following code but when i launch it on my browser nothing happens, i just get a blank screen. can someone please tell me where i've gone wrong?
thanks
<HTML>
<HEAD>
<TITLE>Multiplication table</TITLE>
</HEAD>
<BODY BGCOLOR="purple">
<SCRIPT LANGUAGE="JavaScript">
<!--
// prompts user to enter a value between 1 and 12
function numSelect(){
var check;
var uNum = prompt("Please enter a number between 1 and 12.","");
if (uNum<=0){
check = 1;
}
else if (uNum==""){
check = 1;
}
else if (uNum>=13){
check = 1;
}
else {
check = 0;
}
//If the number selected is not in range, then an alert message will ask the user to select a number that is range
while(check==1){
alert("Sorry the nymber you have not chosen is not in range, please seclect another number");
uNum = prompt("Please enter a number between 1 and 12, inclusive","");
if (uNum<=0){
check = 1;
}
else if (uNum==""){
check = 1;
}
else if (uNum>=13){
check = 1;
}
else {
check = 0;
}
//If the correct number is chosen, then a multiplication table for that number is displayed
if(test==0){
break;
}
}
document.write("<table border='1'>");
document.write("<tr align='center' bgcolor="gray"><td colspan='5'>" + uNum + " Muliplication Table</td></tr>");
var i;
for(i=1;i<13;i++){
if (i%2==1) {
document.write("<tr align='center' bgcolor="blue">");
document.write("<td width='100'>" + i + "</td>");
document.write("<td width='100'>times</td>");
document.write("<td width='100'>" + uNum + "</td>");
document.write("<td width='100'>equals</td>");
document.write("<td width='100'>" + i * uNum + "</td>");
document.write("</tr>");
}
else {
document.write("<tr align='center' bgcolor="yellow">");
document.write("<td width='100'>" + i + "</td>");
document.write("<td width='100'>times</td>");
document.write("<td width='100'>" + uNum + "</td>");
document.write("<td width='100'>equals</td>");
document.write("<td width='100'>" + i * uNum + "</td>");
document.write("</tr>");
}
}
document.write("</table>");
}
// -->
</SCRIPT>
<body onfiltered="numSelect()">
</BODY>
</HTML>
I've entered the following code but when i launch it on my browser nothing happens, i just get a blank screen. can someone please tell me where i've gone wrong?
thanks
<HTML>
<HEAD>
<TITLE>Multiplication table</TITLE>
</HEAD>
<BODY BGCOLOR="purple">
<SCRIPT LANGUAGE="JavaScript">
<!--
// prompts user to enter a value between 1 and 12
function numSelect(){
var check;
var uNum = prompt("Please enter a number between 1 and 12.","");
if (uNum<=0){
check = 1;
}
else if (uNum==""){
check = 1;
}
else if (uNum>=13){
check = 1;
}
else {
check = 0;
}
//If the number selected is not in range, then an alert message will ask the user to select a number that is range
while(check==1){
alert("Sorry the nymber you have not chosen is not in range, please seclect another number");
uNum = prompt("Please enter a number between 1 and 12, inclusive","");
if (uNum<=0){
check = 1;
}
else if (uNum==""){
check = 1;
}
else if (uNum>=13){
check = 1;
}
else {
check = 0;
}
//If the correct number is chosen, then a multiplication table for that number is displayed
if(test==0){
break;
}
}
document.write("<table border='1'>");
document.write("<tr align='center' bgcolor="gray"><td colspan='5'>" + uNum + " Muliplication Table</td></tr>");
var i;
for(i=1;i<13;i++){
if (i%2==1) {
document.write("<tr align='center' bgcolor="blue">");
document.write("<td width='100'>" + i + "</td>");
document.write("<td width='100'>times</td>");
document.write("<td width='100'>" + uNum + "</td>");
document.write("<td width='100'>equals</td>");
document.write("<td width='100'>" + i * uNum + "</td>");
document.write("</tr>");
}
else {
document.write("<tr align='center' bgcolor="yellow">");
document.write("<td width='100'>" + i + "</td>");
document.write("<td width='100'>times</td>");
document.write("<td width='100'>" + uNum + "</td>");
document.write("<td width='100'>equals</td>");
document.write("<td width='100'>" + i * uNum + "</td>");
document.write("</tr>");
}
}
document.write("</table>");
}
// -->
</SCRIPT>
<body onfiltered="numSelect()">
</BODY>
</HTML>