Thread: Need input formula for website I am designing

1. Need input formula for website I am designing

I am in the middle of designing a website and I am pretty new at it. The guy I am designing the website for wants me to make input fields that calculate data that is entered into them. There are 3 formulas that I need to make.
a=b*.262*c
c=a/(b*.262)
b=a/(c*.262)

They are the same formula just solving for different variables. Any help would be awesome!

2. i don't completely understand your question but you should take a look at javascript functions
like:
Code:
```function product(first,second)
{
return first*second;
}

product(5,9) // gives 45 (5*9)```

3. this is the code similar to what I am looking for:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<title></title>
<script type="text/javascript">
lengthObj = document.getElementById('txtLength');
girthObj = document.getElementById('txtGirth');
weightObj = document.getElementById('tdWeight');
document.getElementById('btnReset').onclick = resetInputs;
document.getElementById('btnCalc').onclick = calcWeight;
}
function resetInputs() {
lengthObj.value = '';
girthObj.value = '';
weightObj.innerHTML = '';
}
function calcWeight() {
var length = new Number(lengthObj.value);
var girth = new Number(girthObj.value);
weightObj.innerHTML = '';
if(isNaN(length) || isNaN(girth)) {
alert('Invalid length or girth');
return;
}
weightObj.innerHTML = length*Math.pow(girth,2)/800;
}
</script>
<body>
<table>
<tr>
<td><label for="txtLength">Length (inches)</label></td>
<td><input type="text" id="txtLength" /></td>
</tr>
<tr>
<td><label for="txtGirth">Girth (inches)</label></td>
<td><input type="text" id="txtGirth" /></td>
</tr>
<tr>
<td>SFM</td>
<td id="tdWeight"></td>
</tr>
<tr>
<td></td>
<td><button id="btnReset">Reset</button><button id="btnCalc">Calculate</button></td>
</tr>
</table>
</body>
</html>
the problem is that I don't understand the functions so I can't really edit it.

4. ok...I have been messing around with it a little bit more and I got the first equation to work, but the other 2 don't work now here is my code so far:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<title></title>
<script type="text/javascript">
DObj = document.getElementById('txtD');
RPMObj = document.getElementById('txtRPM');
SFMObj = document.getElementById('tdSFM');
document.getElementById('btnReset').onclick = resetInputs;
document.getElementById('btnCalc').onclick = calcSFM;
}
function resetInputs() {
DObj.value = '';
RPMObj.value = '';
SFMObj.innerHTML = '';
}
function calcSFM() {
var D = new Number(DObj.value);
var RPM = new Number(RPMObj.value);
SFMObj.innerHTML = '';
if(isNaN(D) || isNaN(RPM)) {
alert('Invalid length or girth');
return;
}
SFMObj.innerHTML = D*0.262*RPM;

SFM1Obj = document.getElementById('txtSFM1');
D1Obj = document.getElementById('txtD1');
RPM1Obj = document.getElementById('tdRPM1');
document.getElementById('btnReset1').onclick = resetInputs;
document.getElementById('btnCalc1').onclick = calcRPM1;
}
function resetInputs() {
SFM1Obj.value = '';
D1Obj.value = '';
RPM1Obj.innerHTML = '';
}
function calcSFM() {
var D = new Number(SFM1Obj.value);
var RPM = new Number(D1Obj.value);
RPM1Obj.innerHTML = '';
if(isNaN(SFM1) || isNaN(D1)) {
alert('Invalid length or girth');
return;
}
RPM1Obj.innerHTML = SFM1/(D1*0.262);

SFM2bj = document.getElementById('txtSFM2');
RPM2Obj = document.getElementById('txtRPM2');
D2Obj = document.getElementById('tdD2');
document.getElementById('btnReset2').onclick = resetInputs;
document.getElementById('btnCalc2').onclick = calcD2;
}
function resetInputs() {
SFM2Obj.value = '';
RPM2Obj.value = '';
D2Obj.innerHTML = '';
}
function calcD2() {
var SFM2 = new Number(SFM2Obj.value);
var RPM2 = new Number(RPM2Obj.value);
D2Obj.innerHTML = '';
if(isNaN(SFM2) || isNaN(RPM2)) {
alert('Invalid length or girth');
return;
}
D2Obj.innerHTML = SFM2/(RPM2*0.262);
}

</script>
<body>
<table>
<tr>
<td><label for="txtD">Tool Diameter</label></td>
<td><input type="text" id="txtD" /></td>

<td><label for="txtRPM">RPM</label></td>
<td><input type="text" id="txtRPM" /></td>

<td>SFM=</td>
<td id="tdSFM"></td>
</tr>
<tr>
<td></td>
<td><button id="btnReset">Reset</button><button id="btnCalc">Calculate</button></td>
</tr>
<tr>
<td><label for="txtSFM1">SFM</label></td>
<td><input type="text" id="txtSFM1" /></td>

<td><label for="txtD1">Tool Diameter</label></td>
<td><input type="text" id="txtSFM1" /></td>

<td>RPM=</td>
<td id="tdRPM1"></td>
</tr>
<tr>
<td></td>
<td><button id="btnReset1">Reset</button><button id="btnCalc1">Calculate</button></td>
</tr>
<tr>
<td><label for="txtSFM2">SFM</label></td>
<td><input type="text" id="txtSFM2" /></td>

<td><label for="txtRPM2">RPM</label></td>
<td><input type="text" id="txtRPM2" /></td>

<td>Tool Diameter=</td>
<td id="tdD2"></td>
</tr>
<tr>
<td></td>
<td><button id="btnReset2">Reset</button><button id="btnCalc2">Calculate</button></td>
</tr>
</table>
</body>
</html>

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•