Results 1 to 4 of 4

Thread: javascript error

  1. #1
    Join Date
    May 2015
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default javascript error

    hey guys newbie here, i got a task for my mid test

    Code:
    <html>
    <head>
    <title>Mencetak Grade Dengan Inputan Form</title>
    <script type="text/javascript">
    <!--
    function hitunggrade() {
    var nim=document.frmnilai.txtnim.value;
    var nama=document.frmnilai.txtnama.value;
    var absen=document.frmnilai.txtabsen.value;
    var uts=document.frmnilai.txtuts.value;
    var uas=document.frmnilai.txtuas.value;
    var total=(10/100*absen)+(40/100*uts)+(50/100*uas);
    var grade;
    if (total<=100 && total>=85){
    grade="A";
    } else	if (total<=84 && total>=75){
    grade="B";
    } else if (total<=74 && total>=60){
    grade="C";
    } else if ( total<=59 && total>=0){
    grade="D";
    } else {
    grade="*";
    }
    
    document.write("NIM : " + nim);
    document.write("<br>Nama : " + nama);
    document.write("<br>Nilai Absen : " + absen);
    document.write("<br>Nilai UTS : " + uts);
    document.write("<br>Nilai UAS : " + uas);
    document.write("<br>Nilai Anda : " + total);
    document.write("<br>Grade Anda : " + grade);
    }
    -->
    </script>
    </head>
    
    <body><form name="frmnilai" method="post" action="">
    <table border="0">
    <tr>
    <td align="center" colspan="2">INPUT NILAI MAHASISWA</td>
    </tr>
    <tr>
    <td>NIM</td>
    <td>: <input name="txtnim" type="text" /></td>
    </tr>
    <tr>
    <td>Nama</td>
    <td>: <input name="txtnama" type="text" /></td>
    </tr>
    <tr>
    <td>Nilai Absen</td>
    <td>: <input name="txtabsen" type="text" /></td>
    </tr>
    <tr>
    <td>Nilai UTS</td>
    <td>: <input name="txtuts" type="text" /></td>
    </tr>
    <tr>
    <td>Nilai UAS</td>
    <td>: <input name="txtuas" type="text" /></td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td align="center"><input name="kirim" type="submit"
    value="Hitung Grade" onClick= "hitunggrade()"/></td>
    </tr>
    </table>
    </form>
    </body>
    </html>

    my codes didnt work n i dont know why
    Last edited by jscheuer1; 05-13-2015 at 05:54 AM. Reason: format code

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    What's a mid test?
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    May 2015
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    i mean midterm exam, sorry for my terrible english

  4. #4
    Join Date
    Mar 2011
    Posts
    2,144
    Thanks
    59
    Thanked 116 Times in 113 Posts
    Blog Entries
    4

    Default

    We would encourage you to try and solve any academic problems assigned with minimal help.

    There aren't any javascript errors in the code you provided. There are some issues with it (listed below) but nothing that would prevent your code from running.

    What is the code doing that it shouldn't be doing? (Or what isn't it doing that it should be doing)


    Issue 1
    Your code is lacking formatting. Try indenting your code as it will make debugging it a lot easier.

    Issue 2
    You're missing a valid Doctype at the beginning of your code.

    Issue 3
    The html comments around your javascript (to provide noscript support?) aren't necessary in any browser today.

Similar Threads

  1. Javascript error in IE only
    By Harleyy in forum JavaScript
    Replies: 2
    Last Post: 07-22-2011, 07:14 AM
  2. Javascript with ASP error
    By tufanayd in forum JavaScript
    Replies: 1
    Last Post: 09-26-2009, 02:34 AM
  3. Javascript Error in FF3 and not FF2 (?)
    By Strangeplant in forum JavaScript
    Replies: 3
    Last Post: 10-23-2008, 08:43 PM
  4. Customize the Error Object in JavaScript (Error Handler Script)
    By hari.gomatum in forum Submit a DHTML or CSS code
    Replies: 1
    Last Post: 12-13-2007, 06:56 AM
  5. Javascript error help
    By oriecat in forum JavaScript
    Replies: 5
    Last Post: 12-15-2006, 07:12 AM

Bookmarks

Posting Permissions

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