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 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Jun 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    help me fix this

    i have written a little bit of code for a personal site nothing important or great.
    its a piece of code for a small online game.
    but for some reason when you put in the 2 numbers in the two boxes and click calculate nothing happens. what am i doing wrong here.
    hopefully its just a little bit of code so i dont have to try to rewrite the whole thing differently.
    oh ya im kinda of a newbie lol
    thanks

    heres the code

    <html>
    <head>
    <title>multiples</title>
    <script type = "text/javascript">
    <!--
    function testmult()
    {
    var num1, num2, result;
    num1 = parseint( documents.myform.num1.value);
    num2 = parseint( document.myform.num2.value);

    if ( multiple(num1, num2))
    document.myform.result.value =
    num1 + " is a multiple of " + num2;
    else
    document.myform.result.value =
    num1 + "is not a multiple of " + num2;
    }
    function multiple( var num1, var num2)
    {
    if (( num1 % num2)== 0)
    return true;
    else;
    return false;
    }
    //-->
    </script>
    </head>
    <body>
    <form name ="form1" action = "">
    <table border ="1">
    <tr><td> first</td>
    <td><input name ="num1" type = "text" /></td>
    </tr>
    <tr><td>second</td>
    <td><input name ="num1" type = "text"/>
    </tr>
    <tr><td>result</td>
    <td><input name = "result" type = "text"/>
    </td>
    </tr>
    <tr><td>
    <input type = "button" value = "calculate"
    onclick = "testmult()"/></td>
    </tr>
    </table>
    </form>
    </html>

    thank you for trying to help me .

  • #2
    New to the CF scene
    Join Date
    Jun 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i thought its probably not that big of a problem that a software debugger or somethign could pick it up
    i heard html kit tidy. would that pick it up.?
    is there anyother ones that you could tell me about.?

  • #3
    Regular Coder
    Join Date
    Jan 2003
    Posts
    867
    Thanks
    4
    Thanked 8 Times in 8 Posts
    Mostly just typos...

    Code:
    <html>
    <head>
    <title>multiples</title>
    <script type = "text/javascript">
    <!--
    function testmult()
    {
    var num1, num2, result;
    num1 = parseInt( document.form1.num1.value);
    num2 = parseInt( document.form1.num2.value);
    
    if ( multiple(num1, num2))
    document.form1.result.value = num1 + " is a multiple of " + num2;
    else
    document.form1.result.value = num1 + " is not a multiple of " + num2;
    }
    
    function multiple( num1, num2)
    {
    if (( num1 % num2)== 0)
    return true;
    else
    return false;
    }
    
    //-->
    </script>
    </head>
    <body>
    <form name ="form1" action = "">
    <table border ="1">
    <tr><td> first</td>
    <td><input name ="num1" type = "text" /></td>
    </tr>
    <tr><td>second</td>
    <td><input name ="num2" type = "text"/>
    </tr>
    <tr><td>result</td>
    <td><input name = "result" type = "text"/>
    </td>
    </tr>
    <tr><td>
    <input type = "button" value = "calculate" onclick = "testmult()"/></td>
    </tr>
    </table>
    </form>
    </html>

  • #4
    New to the CF scene
    Join Date
    Jun 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    oh man thank you so much. i was starting to worry about myself. lol

    and by the way any one can answer this how did you do that when you posted the code. that is so much easier to read. that way

    again thanks i see where i was messing up.

  • #5
    New to the CF scene
    Join Date
    Jun 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    man this site is an awsome site.
    who needs to go to school when you have awsome teachers on here.
    and on top of that you help others for free.
    i can see myself becoming an cfaddict like arnyinc.
    well let me go see if i can help others on here too
    ill definetly post a link to this site on my page.. for shure.


  •  

    Posting Permissions

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