Home
> Discussions & Support
> Topic
New to javascript, Pease help!
Posted by user494676
New to javascript, Pease help! December 03, 2010 12:57AM |
Registered: 13 years ago Posts: 1 |
Hi there,
I just started javascript at college and was trying to add a chart for this script I wrote for a Interest calculator,
I keep getting an error saying the name must be a string and correspond to an existing id,
I know this is very basic but any help would be gratly appreciated, thanks!
this is the code;
<html>
<head>
<title>Interest Calculator</title>
<script type="text/javascript" src="jscharts.js"></script>
<script type="text/javascript">
var myData = new Array([10, 20], [15, 10], [20, 30], [25, 10], [30, 5]);
var myChart = new JSChart('chartcontainer', 'line');
myChart.setDataArray(myData);
myChart.draw();
</script>
<script language="JavaScript">
<!--
function irCalc(form){
var p = form.Am.value;
var r = form.Ra.value;
var n = form.Ye.value;
var A = p;
for (var i=1;i<=n; i++){
A = A*(1+r/100);
}
var rounded=Math.round(A*100)/100;
displayResult(rounded);
}
function displayResult(rounded) {
newWin = window.open('','NewWindow','width=350, height=200,background-color=red');
newWin.document.open();
newWin.document.write("<html>"
newWin.document.write("<head>"
newWin.document.write("<script type='text/javascript' src='jscharts.js'></script>"
newWin.document.write("<link href='styles.css' rel='stylesheet' type='text/css'>"
newWin.document.write("</head>"
newWin.document.write("<body class='bgcolour'>"
newWin.document.write("Total amout is £" + rounded + ". Enjoy."
newWin.document.write("<div id='chartcontainer'> This is just a replacement in case Javascript is not available or used for SEO purposes</div>"
newWin.document.write("</body>"
newWin.document.write("</html>"
newWin.documnet.close();
}
-->
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="styles.css" rel="stylesheet" type="text/css">
</head>
<form method="GET" name="IC" class="center_allign">
Amount Invested:<input type="text" name="Am"><br><br>
Interest Rate (%):<input type="text" name="Ra"><br><br>
Number of Years:<input type="text" name="Ye"><br><br>
<input type="button" name="button" Value="Calculate!" onClick="irCalc(this.form);">
</form>
<body class="bgcolour">
</body>
</html>
I just started javascript at college and was trying to add a chart for this script I wrote for a Interest calculator,
I keep getting an error saying the name must be a string and correspond to an existing id,
I know this is very basic but any help would be gratly appreciated, thanks!
this is the code;
<html>
<head>
<title>Interest Calculator</title>
<script type="text/javascript" src="jscharts.js"></script>
<script type="text/javascript">
var myData = new Array([10, 20], [15, 10], [20, 30], [25, 10], [30, 5]);
var myChart = new JSChart('chartcontainer', 'line');
myChart.setDataArray(myData);
myChart.draw();
</script>
<script language="JavaScript">
<!--
function irCalc(form){
var p = form.Am.value;
var r = form.Ra.value;
var n = form.Ye.value;
var A = p;
for (var i=1;i<=n; i++){
A = A*(1+r/100);
}
var rounded=Math.round(A*100)/100;
displayResult(rounded);
}
function displayResult(rounded) {
newWin = window.open('','NewWindow','width=350, height=200,background-color=red');
newWin.document.open();
newWin.document.write("<html>"
newWin.document.write("<head>"
newWin.document.write("<script type='text/javascript' src='jscharts.js'></script>"
newWin.document.write("<link href='styles.css' rel='stylesheet' type='text/css'>"
newWin.document.write("</head>"
newWin.document.write("<body class='bgcolour'>"
newWin.document.write("Total amout is £" + rounded + ". Enjoy."
newWin.document.write("<div id='chartcontainer'> This is just a replacement in case Javascript is not available or used for SEO purposes</div>"
newWin.document.write("</body>"
newWin.document.write("</html>"
newWin.documnet.close();
}
-->
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="styles.css" rel="stylesheet" type="text/css">
</head>
<form method="GET" name="IC" class="center_allign">
Amount Invested:<input type="text" name="Am"><br><br>
Interest Rate (%):<input type="text" name="Ra"><br><br>
Number of Years:<input type="text" name="Ye"><br><br>
<input type="button" name="button" Value="Calculate!" onClick="irCalc(this.form);">
</form>
<body class="bgcolour">
</body>
</html>
Sorry, you do not have permission to post/reply in this forum.