So the code this piece of the code I'm writing is pretty simple. I have empty input text boxes, and when I click the button a predetermined set of numbers appears in the textboxes. Badda Bing Badda Boom. Except, I can't seem to get them to appear -.-;; and I'm having trouble spotting the bug that could be disrupting this piece.
So pretty much it's still adding numbers into the boxes - however, I just added another piece of code (the min and max things) that I haven't done anything with yet (though I do in need them later) and now the "no numbers" things is starting up again. So even though these min and max functions are being put to use - are they effecting my numbers appearing?
and now the "no numbers" things is starting up again.
That's because your function "minarr" is failing to compile ...
This might be a more buggy question(or perhaps not) - now I'm using Explorer (though normally I use Chrome...
Well I think you should stick to IE when debugging. You may ask "why?" - "Chrome has a better console!"
I agree I like "chrome console" - it's the best in inspecting and testing your expressions before writing them. But when it comes to debugging IE is more useful. And has the best feedback on error reports and more precision in pinpointing them.
@Troy - What editor are you using? I'm just using regular wordpad thing o.o
Instead of creating a new thread I decided to build up on this one for pretty much the same program just more developed. So I'm having a problem for making the points and lines show up in my yellow grid table.
Code:
<!doctype html>
<html>
<head>
<style type="text/css">
table {border-collapse:collapse}
</style>
<script type="text/javascript">
L=211;
n1=8;
var a1, a2, a3, a4, a5, a6, a7, a8;
function maxarr(arr,len){
max2= -1.0e10;
for (i=0; i<len; i++)
if(max2 < arr[i])
max2 = arr[i];
return max2;
}
function minarr(arr,len){
max3= 1.0e10;
for (i=0; i<len; i++)
if(max3 > arr[i])
max3 = arr[i];
return max3;
}
function lingrow(){
document.form1.input1.value=10;
document.form1.input2.value=20;
document.form1.input3.value=30;
document.form1.input4.value=40;
document.form1.input5.value="";
document.form1.input6.value="";
document.form1.input7.value="";
document.form1.input8.value="";
document.form1.analysis.value="";
}
function expgrow(){
document.form1.input1.value=2;
document.form1.input2.value=4;
document.form1.input3.value=8;
document.form1.input4.value=16;
document.form1.input5.value="";
document.form1.input6.value="";
document.form1.input7.value="";
document.form1.input8.value="";
document.form1.analysis.value="";
}
function shrink(){
document.form1.input1.value=256;
document.form1.input2.value=128;
document.form1.input3.value=64;
document.form1.input4.value=32;
document.form1.input5.value="";
document.form1.input6.value="";
document.form1.input7.value="";
document.form1.input8.value="";
document.form1.analysis.value="";
}
function forecast(){
a1=parseFloat(document.form1.input1.value);
a2=parseFloat(document.form1.input2.value);
a3=parseFloat(document.form1.input3.value);
a4=parseFloat(document.form1.input4.value);
c1=a2-a1;
c2=a3-a2;
c3=a4-a3;
cmax=Math.max(Math.abs(c1), Math.abs(c2), Math.abs(c3));
cmin=Math.min(Math.abs(c1), Math.abs(c2), Math.abs(c3));
err=cmax-cmin;
avga=(a1+a2+a3+a4)/4;
erra=err/avga;
avgc=(c1+c2+c3)/3;
e1=a2/a1;
e2=a3/a2;
e3=a4/a3;
emax=Math.max(e1,e2,e3);
emin=Math.min(e1,e2,e3);
errg=emax-emin;
avge=(e1+e2+e3)/3;
if(errg>erra)stype="A";
else stype="G";
if(stype=="A"){
a5=a4+avgc;
a6=a5+avgc;
a7=a6+avgc;
a8=a7+avgc;
}
else{
a5=a4*avge;
a6=a5*avge;
a7=a6*avge;
a8=a7*avge;
}
document.form1.input5.value=a5.toFixed(2);
document.form1.input6.value=a6.toFixed(2);
document.form1.input7.value=a7.toFixed(2);
document.form1.input8.value=a8.toFixed(2);
msglin='Your data is more like a linear trend than a % growth. ';
msglin= msglin+'The average change per period is '+avgc+'%';
msgexpgr='Your data is more like an exponential growth. ';
avgrgr=100.*(avge-1.0);
avgrgr=avgrgr.toFixed(2);
msgexpgr=msgexpgr+'The average growth per period is '+avgrgr+'%';
msgshrink='Your data is more like a shrink reduction. ';
avgrred=100.*(1.0-avge);
avgrred=avgrred.toFixed(2);
msgshrink=msgshrink+'The average reduction per period is '+avgrred+'%';
if(stype=="A")document.form1.analysis.value=msglin;
else if(avge>1.0) document.form1.analysis.value=msgexpgr;
else document.form1.analysis.value=msgshrink;
}
function point(xm,ym,colorp){
ym=Math.round(ym);
xm=Math.round(xm);
id=(L-ym+1)+","+xm;
cell1=document.getElementById(id);
cell1.style.backgroundColor=colorp;
}
function points(xm,ym,colorp,n){
n2=Math.floor(n/2);
for(i1=0;i1<n;i1++)
for(j1=0; j1<n; j1++)
point(xm-n2+i1, ym-n2+ji, colorp);
}
function line1(xm,ym,xn,yn,colorp){
m=(yn-ym)*1/(xn-xm);
if(Math.abs(xn-xm) >= Math.abs(yn-ym)){
for(j=xm;j<=xn;j++){
y=m*(j-xm)+ym;
point(j,y,colorp);
}
}
else{
ymax=Math.max(ym,yn);
ymin=Math.min(ym,yn);
for(i1=ymin;i1<=ymax;i1++){
x=(i1-ym)/m+xm;
point(x,i1,colorp);
}
}
}
function plot(){
xs1=new Array();
ys1=new Array(a1,a2,a3,a4,a5,a6,a7,a8);
ys2=new Array();
max1=maxray(ys1,n1);
min1=minray(ys1,n1);
for(i=0;i<n1;i++)
ys2[i]=(ys1[i]-min1)/(max1-min1)*(L-20)+10;
for(i=0;i<n1;i++)
xs1[i]=Math.round((L-20)/(n1-1)*i+10);
for(i=0;i<n1/2;i++){
line1(xs1[i],ys2[i],xs1[i+1],ys2[i+1], "brown");
points(xs1[i],ys2[i],"brown",3);
}
for(i=n1/2;i<n1;i++){
if(i!=n1-1)
line1(xs1[i],ys2[i],xs1[i+1],ys2[i+1],"blue");
points(xs1[i],ys2[i],"blue",3);
}
}
</script>
</head>
<body>
<form name="form1">
Your Quarterly Numbers: <br>
<p><input type="text" size="8" name="input1" />
<input type="text" size="8" name="input2" />
<input type="text" size="8" name="input3" />
<input type="text" size="8" name="input4" />
<p><input type="button" value="Linear Growth" onclick="lingrow()" />
<input type="button" value="Exponential Growth" onclick="expgrow()" />
<input type="button" value="Shrink Reduction" onclick="shrink()" />
<p>Projected Future Forecast: <br>
<p><input type="text" size="8" name="input5" />
<input type="text" size="8" name="input6" />
<input type="text" size="8" name="input7" />
<input type="text" size="8" name="input8" />
<p><input type="text" size="115" name="analysis" />
<p><input type="button" value="Forecast" onclick="forecast()" />
<p>Plotting of Data:<br>
<p><input type="button" value="Plot" onclick="plot()" />
<input type="button" value="Clear plot" onclick="clearplot()" />
</form>
<table>
<script>
wx=500;
wy=600;
dx=Math.floor(wx/L);
dy=Math.floor(wy/L);
for(i=0;i<L;i++){
document.write("<tr>");
for(j=0;j<L;j++){
color="yellow";
id=j+","+i;
document.write("<td id="+id+" style='background-color:"+color+";width:"+dx+";height:"+dy+"'></td>");
}
document.write("</tr>");
}
</script>
</table>
</body>
</html>
@Troy - What editor are you using? I'm just using regular wordpad thing o.o
Instead of creating a new thread I decided to build up on this one for pretty much the same program just more developed. So I'm having a problem for making the points and lines show up in my yellow grid table.
Code:
<!doctype html>
<html>
<head>
<style type="text/css">
table {border-collapse:collapse}
</style>
<script type="text/javascript">
L=211;
n1=8;
var a1, a2, a3, a4, a5, a6, a7, a8;
function maxarr(arr,len){
max2= -1.0e10;
for (i=0; i<len; i++)
if(max2 < arr[i])
max2 = arr[i];
return max2;
}
function minarr(arr,len){
max3= 1.0e10;
for (i=0; i<len; i++)
if(max3 > arr[i])
max3 = arr[i];
return max3;
}
function lingrow(){
document.form1.input1.value=10;
document.form1.input2.value=20;
document.form1.input3.value=30;
document.form1.input4.value=40;
document.form1.input5.value="";
document.form1.input6.value="";
document.form1.input7.value="";
document.form1.input8.value="";
document.form1.analysis.value="";
}
function expgrow(){
document.form1.input1.value=2;
document.form1.input2.value=4;
document.form1.input3.value=8;
document.form1.input4.value=16;
document.form1.input5.value="";
document.form1.input6.value="";
document.form1.input7.value="";
document.form1.input8.value="";
document.form1.analysis.value="";
}
function shrink(){
document.form1.input1.value=256;
document.form1.input2.value=128;
document.form1.input3.value=64;
document.form1.input4.value=32;
document.form1.input5.value="";
document.form1.input6.value="";
document.form1.input7.value="";
document.form1.input8.value="";
document.form1.analysis.value="";
}
function forecast(){
a1=parseFloat(document.form1.input1.value);
a2=parseFloat(document.form1.input2.value);
a3=parseFloat(document.form1.input3.value);
a4=parseFloat(document.form1.input4.value);
c1=a2-a1;
c2=a3-a2;
c3=a4-a3;
cmax=Math.max(Math.abs(c1), Math.abs(c2), Math.abs(c3));
cmin=Math.min(Math.abs(c1), Math.abs(c2), Math.abs(c3));
err=cmax-cmin;
avga=(a1+a2+a3+a4)/4;
erra=err/avga;
avgc=(c1+c2+c3)/3;
e1=a2/a1;
e2=a3/a2;
e3=a4/a3;
emax=Math.max(e1,e2,e3);
emin=Math.min(e1,e2,e3);
errg=emax-emin;
avge=(e1+e2+e3)/3;
if(errg>erra)stype="A";
else stype="G";
if(stype=="A"){
a5=a4+avgc;
a6=a5+avgc;
a7=a6+avgc;
a8=a7+avgc;
}
else{
a5=a4*avge;
a6=a5*avge;
a7=a6*avge;
a8=a7*avge;
}
document.form1.input5.value=a5.toFixed(2);
document.form1.input6.value=a6.toFixed(2);
document.form1.input7.value=a7.toFixed(2);
document.form1.input8.value=a8.toFixed(2);
msglin='Your data is more like a linear trend than a % growth. ';
msglin= msglin+'The average change per period is '+avgc+'%';
msgexpgr='Your data is more like an exponential growth. ';
avgrgr=100.*(avge-1.0);
avgrgr=avgrgr.toFixed(2);
msgexpgr=msgexpgr+'The average growth per period is '+avgrgr+'%';
msgshrink='Your data is more like a shrink reduction. ';
avgrred=100.*(1.0-avge);
avgrred=avgrred.toFixed(2);
msgshrink=msgshrink+'The average reduction per period is '+avgrred+'%';
if(stype=="A")document.form1.analysis.value=msglin;
else if(avge>1.0) document.form1.analysis.value=msgexpgr;
else document.form1.analysis.value=msgshrink;
}
function point(xm,ym,colorp){
ym=Math.round(ym);
xm=Math.round(xm);
id=(L-ym+1)+","+xm;
cell1=document.getElementById(id);
cell1.style.backgroundColor=colorp;
}
function points(xm,ym,colorp,n){
n2=Math.floor(n/2);
for(i1=0;i1<n;i1++)
for(j1=0; j1<n; j1++)
point(xm-n2+i1, ym-n2+ji, colorp);
}
function line1(xm,ym,xn,yn,colorp){
m=(yn-ym)*1/(xn-xm);
if(Math.abs(xn-xm) >= Math.abs(yn-ym)){
for(j=xm;j<=xn;j++){
y=m*(j-xm)+ym;
point(j,y,colorp);
}
}
else{
ymax=Math.max(ym,yn);
ymin=Math.min(ym,yn);
for(i1=ymin;i1<=ymax;i1++){
x=(i1-ym)/m+xm;
point(x,i1,colorp);
}
}
}
function plot(){
xs1=new Array();
ys1=new Array(a1,a2,a3,a4,a5,a6,a7,a8);
ys2=new Array();
max1=maxray(ys1,n1);
min1=minray(ys1,n1);
for(i=0;i<n1;i++)
ys2[i]=(ys1[i]-min1)/(max1-min1)*(L-20)+10;
for(i=0;i<n1;i++)
xs1[i]=Math.round((L-20)/(n1-1)*i+10);
for(i=0;i<n1/2;i++){
line1(xs1[i],ys2[i],xs1[i+1],ys2[i+1], "brown");
points(xs1[i],ys2[i],"brown",3);
}
for(i=n1/2;i<n1;i++){
if(i!=n1-1)
line1(xs1[i],ys2[i],xs1[i+1],ys2[i+1],"blue");
points(xs1[i],ys2[i],"blue",3);
}
}
</script>
</head>
<body>
<form name="form1">
Your Quarterly Numbers: <br>
<p><input type="text" size="8" name="input1" />
<input type="text" size="8" name="input2" />
<input type="text" size="8" name="input3" />
<input type="text" size="8" name="input4" />
<p><input type="button" value="Linear Growth" onclick="lingrow()" />
<input type="button" value="Exponential Growth" onclick="expgrow()" />
<input type="button" value="Shrink Reduction" onclick="shrink()" />
<p>Projected Future Forecast: <br>
<p><input type="text" size="8" name="input5" />
<input type="text" size="8" name="input6" />
<input type="text" size="8" name="input7" />
<input type="text" size="8" name="input8" />
<p><input type="text" size="115" name="analysis" />
<p><input type="button" value="Forecast" onclick="forecast()" />
<p>Plotting of Data:<br>
<p><input type="button" value="Plot" onclick="plot()" />
<input type="button" value="Clear plot" onclick="clearplot()" />
</form>
<table>
<script>
wx=500;
wy=600;
dx=Math.floor(wx/L);
dy=Math.floor(wy/L);
for(i=0;i<L;i++){
document.write("<tr>");
for(j=0;j<L;j++){
color="yellow";
id=j+","+i;
document.write("<td id="+id+" style='background-color:"+color+";width:"+dx+";height:"+dy+"'></td>");
}
document.write("</tr>");
}
</script>
</table>
</body>
</html>
I use the default right-click view source from Explorer when editing which means I'm using Notepad. As, and since forever. Its easier ...
***
I'll have to see into this code and try to understand your question from it than...
Bookmarks