jackam1
08-08-2006, 04:47 PM
Hi
The following code works perfectly(apart from one little problem which we can forget for the time being) on Mac osx, but will not work on pc or mac os9.
I was lucky enough for some one to write the javascript code for me, which I thought it was working fine, until I came to test it on pc.
On PC it has two problems:
1) When you choose the firstdrop down list the second list is supposed to get popluated which it doesn't.
1a) similarly when you choose 2nd drop down, the third one is supposed to get populated. These two problems, I very much succpect are related. If you solve one you ahve solved the other.
2) Again on PC the the values that need to be calculated and sown are not getting displayed.
after entering vales in red, teh green ones are supposed to be calculated automaically. it works fine agian on mac osx , but not on pC.
With my limited knowledge I am assuming its a browser compatibilty problem or maybe a syntax error that soem operating system will ignore but others can be strict.
Your help is much appreciated. The code pasted is not all the data, but for teh sake of simplicity I have included just the first choice numbers.
Your help is very much apprecaited.
As alot of work has gone into this I feel it is a shame to abandon this project as I am so close to getting it to work.
Thanks guys.
code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; ">
<title>Pulley Calculation</title>
<style type="text/css" media="screen">
h1 {font-family: sans-serif; border-bottom: 0.125em solid #F33;
margin-bottom: 0;}
td.lbl {font-weight: bold; text-align: right;}
td {padding:0.25em 1px;}
tr.required td.lbl {background: #FCC; border-left:0.5em solid red;} /* a light red */
tr.required td.inp { font-weight: bold; text-align:center;}
td.lbl {background:#CFC; border-left:0.5em solid green;}
td.inp {color:red; }
div#submitarea {text-align:center;margin-top:1em; padding-top:1em;}
input:focus {background:yellow; }
</style>
<SCRIPT language="JavaScript">
var b16;
//var cd1;
function calculate()
{
var sel1=maths.stage1;
}
</SCRIPT>
</head>
<body>
<br>
<script language="JavaScript" type="text/javascript">
/*<![CDATA[*/
var R1ip,R2ip;
function Populate2(obj){
R1ip=document.getElementById('R1');
R2ip=document.getElementById('R2');
var p1ip=document.getElementById('P1');
var p2ip=document.getElementById('P1');
R1ip.value='';
R2ip.value='';
z1=Number(maths.nosmallpulley.value);
z2=Number(maths.nolargepulley.value);
cd1=Number(maths.cd.value);
pit=(obj.value.split('|')[0]);
p1ip.value=(z1*(obj.value.split('|')[0])/Math.PI).toFixed(3);
lp.value=(z2 *(obj.value.split('|')[0])/Math.PI).toFixed(3);
thirdbox= (cd1*2) +( (z1+z2) *(pit/2)) + ( (z2-z1)* (pit/Math.PI ) * (z2-z1)* (pit/Math.PI ) ) * (1/(4*cd1));
tbl.value= thirdbox.toFixed(3);
//fourthbox=z1;
//ncd.value= fourthbox.toFixed(3);
var blts=obj.value.split('|')[1].split(',');
var sel2=document.getElementById('Sel2');
sel2.options.length=1;
for (var zxc0=0;zxc0<blts.length;zxc0++){
if (blts[zxc0].length>0){;
var opt=Belts[parseInt(blts[zxc0])];
sel2.options[zxc0+1]=new Option(opt[0],opt[1],true,true);
}
}
sel2.selectedIndex=0;
}
function Populate3(obj){
R1ip.value='';
R2ip.value='';
var ary=window[obj.value];
var sel3=document.getElementById('Sel3');
sel3.options.length=1;
for (var zxc0=0;zxc0<ary.length;zxc0++){
sel3.options[zxc0+1]=new Option(ary[zxc0][0],ary[zxc0][1],true,true);
}
sel3.selectedIndex=0;
}
function PopulateR1R2(obj){
R1ip.value='';
R2ip.value='';
if (obj.selectedIndex==0){ return; }
var vals=obj.value.split(',');
//R1ip.value=vals[0]*2;
k= (vals[0]/4) -( (z2+z1)*pit/8);
m1=((z2-z1)*pit/Math.PI) * ((z2-z1)*pit/Math.PI) ;
fourthbox= k + Math.sqrt( k*k- ( m1 /8 ) );
R1ip.value=fourthbox.toFixed(3)
page770= z1/180;
page771= (180/Math.PI)* Math.acos( ((z2-z1)*pit) / (2*Math.PI *Number(R1ip.value)) );
//page771= (180/Math.PI)*Math.acos(
((z2-z1)*pit) / (2*Math.PI *Number(52.689)
);
//page771= (180/Math.PI)*Math.acos(
((z2-z1)*pit) / (2*Math.PI *Number(R1ip.value)
);
fifthbox=page771*page770;
//*page771;
R2ip.value=fifthbox.toFixed(3);
//R1ip.value=vals[0];
//R2ip.value=vals[1];
}
var Belts=[];
Belts[0]=['Belt 0','List1'];
Belts[1]=['T2.5','List2'];
Belts[2]=['HTD3','List8'];
Belts[3]=['T5','List3'];
Belts[4]=['T5/DL','List4'];
Belts[5]=['AT5','List10'];
Belts[6]=['HTD5','List11'];
Belts[7]=['HTD8','List9'];
Belts[8]=['T10','List5'];
Belts[9]=['T10/DL','List6'];
Belts[10]=['AT10','List12'];
Belts[11]=['HTD14','List13'];
Belts[12]=['T20','List7'];
Belts[13]=['AT20','List14'];
Belts[14]=['MP','List22'];
Belts[15]=['MXL','List15'];
Belts[16]=['XL','List16'];
Belts[17]=['XL/DL','List17'];
Belts[18]=['L','List18'];
Belts[19]=['L/DL','List19'];
Belts[20]=['H','List20'];
Belts[21]=['H/DL','List21'];
var List1=[];
List1[0]=['List 1 - 0','111,21']
List1[1]=['List 1 - 1','123,1234']
List1[2]=['List 1 - 2','2344,456']
List1[3]=['List 1 - 3','567,342']
var List2=[];
List2[0]=['55','55,6666']
List2[1]=['120','120,6666']
List2[2]=['145','145,2222']
List2[3]=['160','160,4444']
List2[4]=['177.5','177.5,4444']
List2[5]=['180','180,4444']
List2[6]=['182.5','182.5,4444']
List2[7]=['200','200,4444']
List2[8]=['210','210,4444']
List2[9]=['230','230,4444']
List2[10]=['245','245,4444']
List2[11]=['265','265,4444']
List2[12]=['285','285,4444']
List2[13]=['290','290,4444']
List2[14]=['305','305,4444']
List2[15]=['317.5','317.5,4444']
List2[16]=['330','330,4444']
List2[17]=['380','380,4444']
List2[18]=['420','420,4444']
List2[19]=['480','480,4444']
List2[20]=['492.5','492,4444']
List2[21]=['500','500,4444']
List2[22]=['540','540,4444']
List2[23]=['600','600,4444']
List2[24]=['620','620,4444']
List2[25]=['650','650,4444']
List2[26]=['680','680,4444']
List2[27]=['915','915,4444']
List2[28]=['950','950,4444']
List2[29]=['1300','1300,4444']
List2[30]=['1750','1750,4444']
/*]]>*/
</script>
<form name ="maths">
<h1>Pulley centre Calculation</h1>
<table cellspacing="0">
<tr class="required">
<td class="lbl">No of Teeth in Small Pulley </td>
<td class="inp"><input type="text" name="nosmallpulley" size="20" maxlength="8" onBlur="calculate();"></td>
</tr>
<tr class="required">
<td class="lbl">No of Teeth in Large Pulley </td>
<td class="inp"><input type="text" name="nolargepulley" size="20" maxlength="8" onBlur="calculate();"> </td>
</tr>
<tr class="required">
<td class="lbl">Centre Distant ( mm </td>
<td class="inp"><input type="text" name="cd" size="20" maxlength="8" onBlur="calculate();"></td>
</tr>
<tr class="required">
<td class="lbl">Pitch ( mm) </td>
<td class="inp">
<select onchange="Populate2(this);" >
<option value=" |" >Belt Size</option>
<option value="2.5|1" >2.5 mm</option>
<option value="3|2" >3 mm</option>
<option value="5|3,4,5,6" >5 mm</option>
<option value="8|7" >8 mm</option>
<option value="10|8,9,10" >10 mm</option>
<option value="14|11" >14 mm</option>
<option value="20|12,13" >20 mm</option>
<option value="2.032|14,15" >2.032 mm (0.08")</option>
<option value="5.08|16,17" >5.08 mm (0.20")</option>
<option value="9.525|18,19" >9.525 mm (3/8")</option>
<option value="12.7|20,21" >12.7mm (1/2")</option>
</select>
</td>
</tr>
<tr>
<td class="lbl">
Small Pulley PCD ( mm)</td>
<td class="inp">
<input id="P1" >
</td>
</tr>
<tr>
<td class="lbl">
Large Pulley PCD ( mm)</td>
<td>
<input id="lp" ></td>
</tr>
<tr>
<td class="lbl">
Theoretical Belt length ( mm)</td>
<td class="inp">
<input id="tbl" >
</td>
</tr>
<tr class="required">
<td class="lbl">
Please choose nearest standard Belt Length (mm)</td>
<td class="inp"
<select id="Sel2" onchange="Populate3(this);" >
<option value="" >Matched Belts</option>
</select>
<select id="Sel3" onchange="PopulateR1R2(this);">
<option value="X" >Belt Lengths</option>
</select>
</td>
</tr>
<tr>
<td class="lbl">
Nominal Centre Distance ( mm)</td>
<td class="inp">
<input id="R1" >
</td>
</tr>
<tr>
<td class="lbl">
Number of Teeth in Mesh ( mm)</td>
<td class="inp">
<input id="R2" >
</td>
</tr>
</table>
<div id="submitarea">
<input type="submit" value="Reset"><br>
Filelds highlighted with red labels <strong> must</strong> be filled in
</div>
</form>
</body>
</html>
jack
The following code works perfectly(apart from one little problem which we can forget for the time being) on Mac osx, but will not work on pc or mac os9.
I was lucky enough for some one to write the javascript code for me, which I thought it was working fine, until I came to test it on pc.
On PC it has two problems:
1) When you choose the firstdrop down list the second list is supposed to get popluated which it doesn't.
1a) similarly when you choose 2nd drop down, the third one is supposed to get populated. These two problems, I very much succpect are related. If you solve one you ahve solved the other.
2) Again on PC the the values that need to be calculated and sown are not getting displayed.
after entering vales in red, teh green ones are supposed to be calculated automaically. it works fine agian on mac osx , but not on pC.
With my limited knowledge I am assuming its a browser compatibilty problem or maybe a syntax error that soem operating system will ignore but others can be strict.
Your help is much appreciated. The code pasted is not all the data, but for teh sake of simplicity I have included just the first choice numbers.
Your help is very much apprecaited.
As alot of work has gone into this I feel it is a shame to abandon this project as I am so close to getting it to work.
Thanks guys.
code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; ">
<title>Pulley Calculation</title>
<style type="text/css" media="screen">
h1 {font-family: sans-serif; border-bottom: 0.125em solid #F33;
margin-bottom: 0;}
td.lbl {font-weight: bold; text-align: right;}
td {padding:0.25em 1px;}
tr.required td.lbl {background: #FCC; border-left:0.5em solid red;} /* a light red */
tr.required td.inp { font-weight: bold; text-align:center;}
td.lbl {background:#CFC; border-left:0.5em solid green;}
td.inp {color:red; }
div#submitarea {text-align:center;margin-top:1em; padding-top:1em;}
input:focus {background:yellow; }
</style>
<SCRIPT language="JavaScript">
var b16;
//var cd1;
function calculate()
{
var sel1=maths.stage1;
}
</SCRIPT>
</head>
<body>
<br>
<script language="JavaScript" type="text/javascript">
/*<![CDATA[*/
var R1ip,R2ip;
function Populate2(obj){
R1ip=document.getElementById('R1');
R2ip=document.getElementById('R2');
var p1ip=document.getElementById('P1');
var p2ip=document.getElementById('P1');
R1ip.value='';
R2ip.value='';
z1=Number(maths.nosmallpulley.value);
z2=Number(maths.nolargepulley.value);
cd1=Number(maths.cd.value);
pit=(obj.value.split('|')[0]);
p1ip.value=(z1*(obj.value.split('|')[0])/Math.PI).toFixed(3);
lp.value=(z2 *(obj.value.split('|')[0])/Math.PI).toFixed(3);
thirdbox= (cd1*2) +( (z1+z2) *(pit/2)) + ( (z2-z1)* (pit/Math.PI ) * (z2-z1)* (pit/Math.PI ) ) * (1/(4*cd1));
tbl.value= thirdbox.toFixed(3);
//fourthbox=z1;
//ncd.value= fourthbox.toFixed(3);
var blts=obj.value.split('|')[1].split(',');
var sel2=document.getElementById('Sel2');
sel2.options.length=1;
for (var zxc0=0;zxc0<blts.length;zxc0++){
if (blts[zxc0].length>0){;
var opt=Belts[parseInt(blts[zxc0])];
sel2.options[zxc0+1]=new Option(opt[0],opt[1],true,true);
}
}
sel2.selectedIndex=0;
}
function Populate3(obj){
R1ip.value='';
R2ip.value='';
var ary=window[obj.value];
var sel3=document.getElementById('Sel3');
sel3.options.length=1;
for (var zxc0=0;zxc0<ary.length;zxc0++){
sel3.options[zxc0+1]=new Option(ary[zxc0][0],ary[zxc0][1],true,true);
}
sel3.selectedIndex=0;
}
function PopulateR1R2(obj){
R1ip.value='';
R2ip.value='';
if (obj.selectedIndex==0){ return; }
var vals=obj.value.split(',');
//R1ip.value=vals[0]*2;
k= (vals[0]/4) -( (z2+z1)*pit/8);
m1=((z2-z1)*pit/Math.PI) * ((z2-z1)*pit/Math.PI) ;
fourthbox= k + Math.sqrt( k*k- ( m1 /8 ) );
R1ip.value=fourthbox.toFixed(3)
page770= z1/180;
page771= (180/Math.PI)* Math.acos( ((z2-z1)*pit) / (2*Math.PI *Number(R1ip.value)) );
//page771= (180/Math.PI)*Math.acos(
((z2-z1)*pit) / (2*Math.PI *Number(52.689)
);
//page771= (180/Math.PI)*Math.acos(
((z2-z1)*pit) / (2*Math.PI *Number(R1ip.value)
);
fifthbox=page771*page770;
//*page771;
R2ip.value=fifthbox.toFixed(3);
//R1ip.value=vals[0];
//R2ip.value=vals[1];
}
var Belts=[];
Belts[0]=['Belt 0','List1'];
Belts[1]=['T2.5','List2'];
Belts[2]=['HTD3','List8'];
Belts[3]=['T5','List3'];
Belts[4]=['T5/DL','List4'];
Belts[5]=['AT5','List10'];
Belts[6]=['HTD5','List11'];
Belts[7]=['HTD8','List9'];
Belts[8]=['T10','List5'];
Belts[9]=['T10/DL','List6'];
Belts[10]=['AT10','List12'];
Belts[11]=['HTD14','List13'];
Belts[12]=['T20','List7'];
Belts[13]=['AT20','List14'];
Belts[14]=['MP','List22'];
Belts[15]=['MXL','List15'];
Belts[16]=['XL','List16'];
Belts[17]=['XL/DL','List17'];
Belts[18]=['L','List18'];
Belts[19]=['L/DL','List19'];
Belts[20]=['H','List20'];
Belts[21]=['H/DL','List21'];
var List1=[];
List1[0]=['List 1 - 0','111,21']
List1[1]=['List 1 - 1','123,1234']
List1[2]=['List 1 - 2','2344,456']
List1[3]=['List 1 - 3','567,342']
var List2=[];
List2[0]=['55','55,6666']
List2[1]=['120','120,6666']
List2[2]=['145','145,2222']
List2[3]=['160','160,4444']
List2[4]=['177.5','177.5,4444']
List2[5]=['180','180,4444']
List2[6]=['182.5','182.5,4444']
List2[7]=['200','200,4444']
List2[8]=['210','210,4444']
List2[9]=['230','230,4444']
List2[10]=['245','245,4444']
List2[11]=['265','265,4444']
List2[12]=['285','285,4444']
List2[13]=['290','290,4444']
List2[14]=['305','305,4444']
List2[15]=['317.5','317.5,4444']
List2[16]=['330','330,4444']
List2[17]=['380','380,4444']
List2[18]=['420','420,4444']
List2[19]=['480','480,4444']
List2[20]=['492.5','492,4444']
List2[21]=['500','500,4444']
List2[22]=['540','540,4444']
List2[23]=['600','600,4444']
List2[24]=['620','620,4444']
List2[25]=['650','650,4444']
List2[26]=['680','680,4444']
List2[27]=['915','915,4444']
List2[28]=['950','950,4444']
List2[29]=['1300','1300,4444']
List2[30]=['1750','1750,4444']
/*]]>*/
</script>
<form name ="maths">
<h1>Pulley centre Calculation</h1>
<table cellspacing="0">
<tr class="required">
<td class="lbl">No of Teeth in Small Pulley </td>
<td class="inp"><input type="text" name="nosmallpulley" size="20" maxlength="8" onBlur="calculate();"></td>
</tr>
<tr class="required">
<td class="lbl">No of Teeth in Large Pulley </td>
<td class="inp"><input type="text" name="nolargepulley" size="20" maxlength="8" onBlur="calculate();"> </td>
</tr>
<tr class="required">
<td class="lbl">Centre Distant ( mm </td>
<td class="inp"><input type="text" name="cd" size="20" maxlength="8" onBlur="calculate();"></td>
</tr>
<tr class="required">
<td class="lbl">Pitch ( mm) </td>
<td class="inp">
<select onchange="Populate2(this);" >
<option value=" |" >Belt Size</option>
<option value="2.5|1" >2.5 mm</option>
<option value="3|2" >3 mm</option>
<option value="5|3,4,5,6" >5 mm</option>
<option value="8|7" >8 mm</option>
<option value="10|8,9,10" >10 mm</option>
<option value="14|11" >14 mm</option>
<option value="20|12,13" >20 mm</option>
<option value="2.032|14,15" >2.032 mm (0.08")</option>
<option value="5.08|16,17" >5.08 mm (0.20")</option>
<option value="9.525|18,19" >9.525 mm (3/8")</option>
<option value="12.7|20,21" >12.7mm (1/2")</option>
</select>
</td>
</tr>
<tr>
<td class="lbl">
Small Pulley PCD ( mm)</td>
<td class="inp">
<input id="P1" >
</td>
</tr>
<tr>
<td class="lbl">
Large Pulley PCD ( mm)</td>
<td>
<input id="lp" ></td>
</tr>
<tr>
<td class="lbl">
Theoretical Belt length ( mm)</td>
<td class="inp">
<input id="tbl" >
</td>
</tr>
<tr class="required">
<td class="lbl">
Please choose nearest standard Belt Length (mm)</td>
<td class="inp"
<select id="Sel2" onchange="Populate3(this);" >
<option value="" >Matched Belts</option>
</select>
<select id="Sel3" onchange="PopulateR1R2(this);">
<option value="X" >Belt Lengths</option>
</select>
</td>
</tr>
<tr>
<td class="lbl">
Nominal Centre Distance ( mm)</td>
<td class="inp">
<input id="R1" >
</td>
</tr>
<tr>
<td class="lbl">
Number of Teeth in Mesh ( mm)</td>
<td class="inp">
<input id="R2" >
</td>
</tr>
</table>
<div id="submitarea">
<input type="submit" value="Reset"><br>
Filelds highlighted with red labels <strong> must</strong> be filled in
</div>
</form>
</body>
</html>
jack