TEXTOVY GRAF

ID
Nazov / Name:
Popis / Description:
Dlzka / Length:
Testovane pod / Tested under:

 

118
p118.html / p118.zip
Po zadani ciselnych udajov zostavi textovy graf a so statistikou
5510b
NN 4.04

UKAZKA / CLICK HERE

Zdrojovy tvar / Source code:

<HTML> <HEAD> <TITLE> JavaScript DESTINATION - P118 </TITLE> <SCRIPT LANGUAGE="JavaScript"> <!-- function createNumArray(n) { this.length=n; for (i=1; i<=10; i++) { this[i]=0; } return this; } function doentry(what) { var x=''; if (what.value!='' && what.value!=' ' && what.value!=' ') { x=eval(what.value); if (x<0 || x>40) { alert('Hodnota je mimo rozsah (0-40)'); what.value=''; } } else what.value=''; dostats(); } var xsumx=0,xsumsqx=0,xmean=0,xsd=0,xsem=0; function dostats() { var counter=0,x=0,xsumx=0,xsumsqx=0,xmean=0,xsd=0,xsem=0; for (i=0; i<10; i++) { if(document.data.xx[i].value) { x=eval(document.data.xx[i].value); xsumx+=x; xsumsqx+=x*x; counter++; } } document.stats.sumx.value=xsumx; document.stats.sumsqx.value=xsumsqx; xmean=xsumx/counter; document.stats.mean.value=xmean; var cf=((xsumx*xsumx)/counter); var variance=(xsumsqx-cf)/(counter-1); var xsd=Math.sqrt(variance); document.stats.sd.value=xsd; } function doGraph() { astr=''; xs=''; xv=0; for (i=0; i<10; i++) { xs=''; xs=document.data.xx[i].value; if (xs=='' || xs==' ' || xs==' ' ) xs='0' xv=eval(xs); astr+=xv+'*'; } astr+='@'; self.location=location.href+'?'+astr; } function arrayParms(astr) { var k=astr.length; astr=astr.substring(1,k); var n=0,a=1,i=1,counter=0; while(a>0) { a=astr.indexOf('*',n) var bstr=astr.substring(n,a) if (bstr!='@' && counter<10 ) { parms[i]=bstr; n=a+1; i++; } else a=0 counter++; } } function xstring(what,n) { var astr=''; for (i=1; i<=n; i++) { astr+=what; } return astr; } function doClearData() { for (i=0; i<10; i++) { document.data.xx[i].value=''; } } function doClearParms() { self.location=self.location.pathname; } var astr=location.search; if (astr!=null & astr !='') { document.write('<CENTER><TABLE BORDER=1 ALIGN=CENTER CELLSPACING=0>') document.write('<TR ALIGN=CENTER><TD><I><B>n</B></I></TD><TD><B>hodnota</B></TD></TR>') var parms=new createNumArray(10),xi; arrayParms(astr); for (xi=1; xi<=10; xi++) { sstr=xstring('×',parms[xi]); document.write('<TR ALIGN=LEFT><TD ALIGN=CENTER>'+xi+'</TD>'); document.write('<TD ALIGN=CENTER>'+parms[xi]+'</TD>'); if (sstr=='') sstr='<BR>'; document.write('<TD>'+sstr+'</TD></TR>'); } document.write('</TABLE></CENTER><BR CLEAR ALL><HR>'); } // --> </SCRIPT> </HEAD> <BODY> <FORM NAME='data'> <TABLE WIDTH=100 ALIGN=RIGHT BORDER=2 CELLPADDING=3 CELLSPACING=0> <TR ALIGN=CENTER> <TD COLSPAN=2><B>Data</B></TD> </TR> <TR ALIGN=CENTER> <TD>1</TD><TD> <INPUT TYPE=text NAME=xx SIZE=3 MAXLENGTH=2 onChange='doentry(this);'> </TD></TR> <TR ALIGN=CENTER> <TD>2</TD><TD> <INPUT TYPE=text NAME=xx SIZE=3 MAXLENGTH=2 onChange='doentry(this);'> </TD></TR> <TR ALIGN=CENTER> <TD>3</TD><TD> <INPUT TYPE=text NAME=xx SIZE=3 MAXLENGTH=2 onChange='doentry(this);'> </TD></TR> <TR ALIGN=CENTER> <TD>4</TD><TD> <INPUT TYPE=text NAME=xx SIZE=3 MAXLENGTH=2 onChange='doentry(this);'> </TD></TR> <TR ALIGN=CENTER> <TD>5</TD><TD> <INPUT TYPE=text NAME=xx SIZE=3 MAXLENGTH=2 onChange='doentry(this);'> </TD></TR> <TR ALIGN=CENTER> <TD>6</TD><TD> <INPUT TYPE=text NAME=xx SIZE=3 MAXLENGTH=2 onChange='doentry(this);'> </TD></TR> <TR ALIGN=CENTER> <TD>7</TD><TD> <INPUT TYPE=text NAME=xx SIZE=3 MAXLENGTH=2 onChange='doentry(this);'> </TD></TR> <TR ALIGN=CENTER> <TD>8</TD><TD> <INPUT TYPE=text NAME=xx SIZE=3 MAXLENGTH=2 onChange='doentry(this)'> </TD></TR> <TR ALIGN=CENTER> <TD>9</TD><TD> <INPUT TYPE=text NAME=xx SIZE=3 MAXLENGTH=2 onChange='doentry(this);'> </TD></TR> <TR ALIGN=CENTER> <TD>10</TD><TD> <INPUT TYPE=text NAME=xx SIZE=3 MAXLENGTH=2 onChange='doentry(this);'> </TD></TR> </TABLE> </FORM> <FORM NAME="stats"> <TABLE WIDTH=150 ALIGN=RIGHT BORDER=2 CELLPADDING=3 CELLSPACING=0> <TR ALIGN=CENTER VALIGN=MIDDLE> <TD><B>Statistika</B></TD> <TD><B>Hodnota</B></TD></TR> <TR ALIGN=CENTER VALIGN=MIDDLE> <TD>Sucet</TD><TD> <INPUT TYPE=text NAME=sumx SIZE=10 MAXLENGTH=10> </TD></TR> <TR ALIGN=CENTER VALIGN=MIDDLE> <TD>Sucet druhych mocnin</TD><TD> <INPUT TYPE=text NAME=sumsqx SIZE=10 MAXLENGTH=10> </TD></TR> <TR ALIGN=CENTER VALIGN=MIDDLE> <TD>Priemer</TD><TD> <INPUT TYPE=text NAME=mean SIZE=10 MAXLENGTH=10> </TD></TR> <TR ALIGN=CENTER VALIGN=MIDDLE> <TD>Standardna deviacia</TD><TD> <INPUT TYPE=text NAME=sd SIZE=10 MAXLENGTH=10> </TD></TR> <TR ALIGN=CENTER VALIGN=MIDDLE> <TD>Standardna chyba</TD><TD> <INPUT TYPE=text NAME=sem SIZE=10 MAXLENGTH=10> </TD></TR> </TABLE> </FORM> V pravej casti tabulky vyplnte datove udaje. Pri vlozeni cisla mimo rozsah, budete na to upozorneny. Pocas vkladania udajov sa priebezne aktualizuje statisticka tabulka. <FORM> <CENTER> <INPUT TYPE=button NAME='doit' VALUE='Sprav graf' onClick='doGraph();'> <INPUT TYPE=button NAME='cldata' VALUE='Zmaz data' onClick='doClearData();'> <INPUT TYPE=button NAME='clparms' VALUE='Zmaz vsetko' onClick='doClearParms();'> </CENTER> </FORM> <PRE> </PRE> </BODY> <SCRIPT> <!-- x=self.location.search if (x.length>2) { for (i=0; i<10; i++) { document.data.xx[i].value=parms[i+1] } } // --> </SCRIPT> </HTML>
[ Navrat / BACK ]