Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Mar 2005
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Can someone please tell how to make this code work

    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>

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    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
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •