matrix - Determinant calculation javascript -


i have got bit of javascript , html code , want display calculated value of matrix determinant, function doesn't want display in input place,where want displayed, instead blank space. html

<div id = "table"> <div id = "header">wyznacznik [3x3]</div>  <form id = "row1">     <input type = "text" class = "det"/><!--first row-->     <input type = "text" class = "det"/>     <input type = "text" class = "det"/>  </form>  <form id = "row2">     <input type = "text" class = "det"/><!--second row-->     <input type = "text" class = "det"/>     <input type = "text" class = "det"/> </form> <form id = "row3">     <input type = "text" class = "det"/><!--third row-->     <input type = "text" class = "det"/>     <input type = "text" class = "det"/> </form> <div class = "count" onclick="det(3)"><a href = "#">wylicz</a></div> <input type = "text" id = "calcvalue"/> </div> 

javascript

function det(size){ var arr = document.getelementsbyclassname('det1'); var determinant = 0; if(size == 2){ determinant = (arr[0].value*arr[3].value) - (arr[1].value*arr[2].value); document.getelementbyid('calcvalue1').value = determinant; } else if(size == 3){ determinant = (arr[0].value*((arr[4].value*arr[8].value) - (arr[5].value *   arr[7].value))) -  (arr[1].value*((arr[3].value*arr[8].value) - (arr[5].value * arr[6].value))) + (arr[2].value*((arr[3].value*arr[7].value) - (arr[4].value * arr[6].value)));  document.getelementbyid('calcvalue').value = determinant; } return determinant; } 

you're getting no elements, try this:

var arr = document.getelementsbyclassname('det'); 

Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -