JavaScript - Standard Deviation & Mean
Hi there, Ive done this so far but I am finding it difficult to calculate the mean and standard deviation. If someone could help me out I would very very grateful. Thanks in advance, Chris.
P.s This is my code so far below. <html> <head> <style type="text/css"> body { background-image:url('Background.jpg') } </style> <style type="text/css"> .container { text-align:center; } .center { margin-left:auto; margin-right:auto; width:37.5%; text-align:left; } </style> <title>Student Results</title> <script language="javascript"> function addRow() { var newRow = document.all("tblGrid").insertRow(); var oCell = newRow.insertCell(); oCell.innerHTML = "<input type='text' name='t1'>"; oCell = newRow.insertCell(); oCell.innerHTML = "<input type='text' name='t2'>"; oCell = newRow.insertCell(); oCell.innerHTML = "<input type='text' name='t3'> <input type='button' value='Delete' onclick='removeRow(this);'/>"; } function removeRow(src) { var oRow = src.parentElement.parentElement; document.all("tblGrid").deleteRow(oRow.rowIndex); } </script> </head> <body> <div class="container"> <div class="center"> <hr> <table id="tblGrid" style="table-layout:fixed"> <tr> <td width="150px">SID</td> <td width="150px">NAME</td> <td width="250px">MARK</td> </tr> <tr> <td><input type="text" name="t1" /></td> <td><input type="text" name="t2" /></td> <td><input type="text" name="t3" /> <input type="button" value="Delete" onclick="removeRow(this);" /></td> </tr> <tr> <td><input type="text" name="t1" /></td> <td><input type="text" name="t2" /></td> <td><input type="text" name="t3" /> <input type="button" value="Delete" onclick="removeRow(this);" /></td> </tr> <tr> <td><input type="text" name="t1" /></td> <td><input type="text" name="t2" /></td> <td><input type="text" name="t3" /> <input type="button" value="Delete" onclick="removeRow(this);" /></td> </tr> <tr> <td><input type="text" name="t1" /></td> <td><input type="text" name="t2" /></td> <td><input type="text" name="t3" /> <input type="button" value="Delete" onclick="removeRow(this);" /></td> </tr> </table> <hr> <input type="button" value="Add Row" onclick="addRow();" /> <hr> </div> </div> </body> <script language="JavaScript"> var pagetitle = document.title; var action = ""; var amount = "0"; var order = ""; var scriptlocation = "/stats/track.asp"; var pagedata = 'mtpt=' + escape(pagetitle) + '&mtac=' + escape(action) + '&mta=' + amount + '&mto=' + escape(order) + '&mtr=' + escape(document.referrer) + '&mtt=2&mts=' + window.screen.width + 'x' + window.screen.height + '&mti=1&mtz=' + Math.random(); document.write ('<img height=1 width=1 '); document.write ('src="' + scriptlocation + '?' + pagedata + '">'); </script> </html> Similar TutorialsHello, i'm all a bit new to javascript and i'm finding it all a bit of a struggle. Using this code i'm looking to allow the user to calculate the mean and standard deviation of scores once they press an appropriate button. Despite looking up many different solutions online i cant get the code to work. Any hints or tips would be hugely appreciated. Code: <html> <head> <title>Student Test Scores</title> <script language="JavaScript"> var studentNameArray = new Array(); var studentScoreArray = new Array(); function addToNameAndScoreArray() { var studentName = document.form.inputStudentName.value; studentNameArray.push(studentName); document.form.nameOutput.value = studentNameArray; var studentScore = document.form.inputStudentScore.value; studentScoreArray.push(studentScore); document.form.scoreOutput.value = studentScoreArray; } function display() { var str="<br>"+"<b>"+"Student Name And Sco "+"</b>"; for(i=0;i<studentNameArray.length;i++) { str=str+"<br>"+studentNameArray[i]; str=str+": "+studentScoreArray[i]; } document.getElementById('displayArray').innerHTML= str; } </script> </head> <body> <center> <h1>Student Scores</h1><br> <form name="form"> Type the students name and score into the appropriate boxes in the <strong>Input Area</strong> below, then click the <strong>Add This Record button</strong>. <br> Click the <strong>Display/Refresh Student Grades</strong> button to show the data thats been entered. <br> The mean and standard deviation can then be calculated when the appropriate buttons are pressed. <p> <br> <hr> <h2>Input Area</h2> <p> <input type="button" onClick="window.location.href=window.location.href" value="Start A New Session"/> <input type="button" onClick="saveCurrentSession();" value="Save Current Session"/><br><br> Student Name: <input type="text" name="inputStudentName" value=""/><br><br> Student Sco <input type="text" name="inputStudentScore" value=""/><br><br> <input type="button" onClick="addToNameAndScoreArray();" value="Add This Record"/><br><br> <input type="button" onClick="removeStudent(name);" value ="Delete This Record"/> <input type="hidden" size="75" name="nameOutput" value=""/><br> <input type="hidden" size="25" name="scoreOutput" value=""/><br> <input type="button" value="Display/Refresh Student Grades" name="button1" onClick="display()"/><br><br> <div id ="displayArray"></div><br> <hr> <br> <h2>Statistics</h2> <p> <input type="button" onClick="" value="Mean"/> <input type="button" onClick="" value="Std. Var."/><br><br> <input type="text" size="15" name="Mean" value=""/> <input type="text" size="15" name="StdVar" value=""/> </center> </body> </html> Hi All, Im trying to write a html with javascript page that reads values from an XML file and outputs to a table. Thats easy i hear you say? Trouble is the application that is outputing the XML file doesnt output a simple XML file. Below is a section of the file: Code: <?xml version="1.0" encoding="UTF-8"?> <CVES name="EUREX" datetime="09 Aug 10 14:40:41"> <thread name="DB 0" state ="active" nb="0" tempo="00:00:02" action="Wait"/> <thread name="DB 1" state ="active" nb="0" tempo="00:00:02" action="Wait"/> <thread name="match" state ="active" nb="0" tempo="00:00:02" action="Wait"/> <MatchingList> <Tickets value="142"/> <TicketsCleared value="23"/> <TicketsNotCleared value="119"/> <Orders value="21"/> <OrdersCleared value="21"/> <OrdersNotCleared value="0"/> </MatchingList> <thread name="exch 1" state ="active" nb="0" tempo="00:00:10" action="Wait"/> <Exchange> <Tickets value="142"/> <TicketsWithUnknownExternalCodes value="212"/> <ClearingInProgress value="4"/> <Clearing> <AverageClearingTime value="00:00:00"/> <LastClearingTime value="14:26:37"/> <LastUnclearingTime value="14:27:55"/> <TotalQtyCleared value="705"/> <TotalQtyUnCleared value=""/> </Clearing> <Reading> <LastReadingTime value="14:40:31"/> <NextReadingTime value="14:41:00"/> im able to read the contents of the CVES tag (Name and datetime) but cannot get any others to load. how can i get details from LastReadingTime? Thread name="Exch 1" Having googled reading XML into HTML file and cannot find anything that covers this kind of xml file THanks I have the non-standard element Code: <testele></testele> In every browser except IE, this bit of JavaScript will successfully change the content of the above element Code: document.getElementsByTagName("testele")[0].innerHTML = 'hi'; However, if I change the <testele> to just a <span> (in the HTML and the JavaScript), it now successfully changes the content of the element in every browser, including IE. Is there any fix? I have searched around and tried a bunch to no avail. Thanks! |