Results 1 to 7 of 7
  1. #1
    Tullamore is offline Member
    Join Date
    Nov 2011
    Posts
    24
    Rep Power
    0

    Default Code question. Where to post.

    I'm working in Aptana on HTML and Javascript. My question is about the Javascript code. Which forum should I post my question in? Thanks in advance.

  2. #2
    Tullamore is offline Member
    Join Date
    Nov 2011
    Posts
    24
    Rep Power
    0

    Default Re: Code question. Where to post.

    I'll try here. This is the application I'm working on:
    http://www.grabilla.com/02405-8a4582...d52be9b54e.png

    I'm trying to get the radio buttons to process.

    Here's my html code:

    Java Code:
    <body>
        <div id="content">
            <h1>Future Value Calculator</h1>
            <p><input type="radio" name="calctype" id="monthly"
    			value="monthly" checked />Monthly Interest</p>
            <p><input type="radio" name="calctype" id="yearly"
    			value="yearly" />Yearly Interest</p>
    		<p>Enter the values below and click "Calculate".</p>
    and here's my Javascript code:

    Java Code:
    var $ = function (id) {
        return document.getElementById(id);
    }
        var status= "unknown";
        if ($("monthly").checked ){
        	status= $("monthly").value;
        }
        if ($("yearly").checked ){
        	status= $("yearly").value;
        }
    var calculate_click = function () {
    	
        var investment = parseFloat( $("investment").value );
        var annualRate = parseFloat( $("rate").value );
        var years = parseInt( $("years").value );
    
    	$("futureValue").value = "";
    	
    	if (isNaN(investment) || investment <= 0) {
    		alert("Investment must be a valid number\nand greater than zero.");
    	} else if(isNaN(annualRate) || annualRate <= 0) {
    		alert("Annual rate must be a valid number\nand greater than zero.");
    	} else if(isNaN(years) || years <= 0) {
    		alert("Years must be a valid number\nand greater than zero.");
    	} else {
    		var monthlyRate = annualRate / 12 / 100;
    		var months = years * 12;
    		var futureValue = investment;
    
    		for ( i = 1; i <= months; i++ ) {
    			futureValue = futureValue  * (1 + monthlyRate);
    		}
    		$("futureValue").value = futureValue.toFixed(2);
    	} 
    }
    
    window.onload = function () {
        $("calculate").onclick = calculate_click;
        $("investment").focus();
    }
    Any help is much appreciated.

  3. #3
    Wnt2bsleepin is offline Senior Member
    Join Date
    Feb 2012
    Posts
    219
    Rep Power
    3

    Default Re: Code question. Where to post.

    This is a Java forum. JavaScript and Java are not the same.

  4. #4
    Tullamore is offline Member
    Join Date
    Nov 2011
    Posts
    24
    Rep Power
    0

    Default Re: Code question. Where to post.

    Oh..alright. Know of any good JavaScript forums that would be helpful by chance?

  5. #5
    Wnt2bsleepin is offline Senior Member
    Join Date
    Feb 2012
    Posts
    219
    Rep Power
    3

    Default Re: Code question. Where to post.

    I do in fact. Here is a good link, that I use. I tried looking at it, but I am better at Java than I am at JavaScript.

  6. #6
    Tullamore is offline Member
    Join Date
    Nov 2011
    Posts
    24
    Rep Power
    0

    Default Re: Code question. Where to post.

    Excellent! Thanks... and thanks for taking a look anyways.

  7. #7
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,458
    Rep Power
    20

    Default Re: Code question. Where to post.

    Off topic, closing

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. First post. with a java question
    By noom14921992 in forum New To Java
    Replies: 1
    Last Post: 04-02-2012, 07:55 AM
  2. First post-Simple question help please
    By Teesea in forum New To Java
    Replies: 2
    Last Post: 08-11-2011, 02:03 PM
  3. Please post your suggestions about this code
    By mathansj in forum Advanced Java
    Replies: 8
    Last Post: 02-15-2009, 04:41 PM
  4. quick pre/post increment question
    By xtrmi in forum New To Java
    Replies: 4
    Last Post: 02-01-2009, 06:47 PM
  5. The first post and first question
    By m_kaleia in forum New To Java
    Replies: 8
    Last Post: 07-19-2008, 07:27 PM

Posting Permissions

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