...

View Full Version : Can someone please tell how to make this code work



Sofia
03-15-2005, 06: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>

A1ien51
03-15-2005, 06:21 PM
Posted this in the wrong forum. Read the rules! This one is for completed scripts, not scripts with errors!

Looking at your code I see an

error here
document.write("<tr align='center' bgcolor="blue">");

and here
document.write("<tr align='center' bgcolor="yellow">");

you have double quotes inside double quotes...You need replace them with single quotes or escape them.

Eric



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum