Thread: Simple java script program
-
March 4th, 2012, 08:57 AM #1Junior Member
- Join Date
- Mar 2012
- Posts
- 1
Simple java script program
Hi
I am a beginner in JS and wanted to write a few simple programs to get accustomed with the syntax and logic of this language. One of the simple programs that I intended to write was for calculating the determinant of a grade 2 matrix.
I have tried since yesterday to understand what's wrong with the program but I just can't figure it out and it seems harder to me since I don't have a compiler like in C++.
If someone could take a look and point out what's wrong I would greatly appreciate it.
Here's the code:
<html>
<head>
<title>Calculating 2 grade matrix determinant program</title>
<script>
function parseEl (elString) {
a11 = parseFloat (document.getElementById"a11".value);
a12 = parseFloat (document.getElementById"a12".value);
b11 = parseFloat (document.getElementById"b11".value);
b12 = parseFloat (document.getElementById"b12".value);
}
function calcDet () {
var a11 = parseEl(document.getElementById"a11".value);
var a12 = parseEl(document.getElementById"a12".value);
var b11 = parseEl(document.getElementById"b11".value);
var b12 = parseEl(document.getElementById"b12".value);
/*if (document.getElementById("a11").value == "")
alert("Nu ati introdus valoare pentru a11.");
if (document.getElementById("a12").value == "")
alert("Nu ati introdus valoare pentru a12.");
if (document.getElementById("b11").value == "")
alert("Nu ati introdus valoare pentru b11.");
if (document.getElementById("b12").value == "")
alert("Nu ati introdus valoare pentru b12.");
else */
det = a11 * b12 - a12 * b11
alert ("Determinantul este: " + det);
}
</script>
</head>
<body style="background-color: #777; color: ddd;">
<div style="margin: 20px;">This program calculates the determinant of a 2 grade matrix</div>
<form name="Det Matrice">
<div style="margin-top: 100px; float: left; width: 100%;">
Enter data:
<table style="text-align: center;">
<tr>
<td><input type="text" id="a11" name="a11" value="a11"></td>
<td><input type="text" id="a12" name="a12" value="a12"></td>
</tr>
<tr>
<td><input type="text" id="b11" name="b11" value="b11"></td>
<td><input type="text" id="b12" name="b12" value="b12"></td>
</tr>
</table>
<br>
</div>
<div style="float: left; margin-top: 20px;">
<input type="button" name="Calculate determinant" value="Calculate determinant" onclick="calcDet ();">
</div>
</form>
</body>
</html>Last edited by elfwind; March 4th, 2012 at 09:03 AM.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
Java Script Help
By machackr in forum Webmastering and ProgrammingReplies: 1Last Post: April 19th, 2009, 07:10 PM -
What Java Script is this?
By Christato in forum Webmastering and ProgrammingReplies: 4Last Post: November 28th, 2008, 06:57 PM -
Italicizing output for simple Java Program
By Canadian in forum Webmastering and ProgrammingReplies: 6Last Post: November 11th, 2005, 07:28 PM -
Simple Script
By Rand Dusing in forum Webmastering and ProgrammingReplies: 0Last Post: October 14th, 2003, 07:28 PM



LinkBack URL
About LinkBacks



Reply With Quote

I know there is plenty of tutorials for putting Snow Leopard on a PC but I couldn't find one particular to what I have. I have a Laptop with Windows 7 on it. I really don't use it for anything and...
Snow Leopard on a PC