Results 1 to 3 of 3

Thread: JS Function Not Working

  1. #1
    Join Date
    Jun 2010

    JS Function Not Working

    I have a js function that mostly works. When the If statement isn't there, it works just great. But when I put the if statement in, I get nothing back. It's a very simple thing so I don't see where I'm going wrong.

    PHP Code:
    <script type='text/javascript'>
    function monthly_calc(x) {
    // Get values from form
    amount = getDocumentById('amount'+x).value;
    frequency = getDocumentById('frequency'+x).value;
    when = getDocumentById('when'+x).value;

    // Compute the product.
    var product = amount * when * frequency;

    // Display product in form.

    function test(id) {
        var test_amount= "test"+id;
        var amount = document.getElementById('test'+id).value;
        var product = amount * 100;
        If(product > 0) {
        Else {

  2. #2
    Join Date
    Aug 2007
    JavaScript is case-sensitive. So it's if and else not If and Else.

    For future debugging, I suggest the Firefox Error console (Tools -> Error Console), and the Firebug addon.
    Great wit and madness are near allied, and fine a line their bounds divide.

  3. #3
    Join Date
    Jun 2010
    Thanks! I'll get that add on. I didn't know js was case sensitive that way.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

Recent Articles