Car BHP calculator, Check ur car's horsepower - HTML / Javascript Tutorials
 
  Buy Ebooks, Video Games, DVDs, Electronics and more !
Home | Help Forums | Web Design Tutorials | Free Swishmax Downloads Make Money Online Blog . Free Image and Photo Sharing and Hosting

 

 

Company

Home

Nework Details

Tutorials

SWiSH 2

SWiSHMax

Flash MX

PHP & MySQL

HTML / JScript

Adobe Photoshop

Corel Draw

Gimp

Miscellaneous

Downloads

Templates

Plugins

Fonts

Wallpapers

Free Images

Scripts and Codes

Products

E-Books

SWiSH BB

SWiSH Templates

SWiSH-DB Newsletter
Subscribe to our newsletter : GO
  Partners / Affiliates

   Free image hosting
   Web Design Pakistan
   Swish Templates
   SWiSH Climax
   Talkfreelance Community
   Template Desire
   Lite boards
   Script Sector
   GimpTalk
   13dots
   Idea Designs
   PHP Cafe
   Sposatoettore
   Free swishmax templates
   Swishzone

Manage your site with Flax Article Content Management System
Car BHP calculator, Check ur car's horsepower
Category : HTML / Javascript | Level : Beginner | Language : English
Ask Question | Read Comments | Post tutorial | Previous | Next

Web www.swish-db.com

Who doesnt have a Car these days......and ofcourse the owners would like to know their car's exact horse power......and u too wink.gif
This script will tell u the horse power of your car by just putting the weight of the car(including the driver) and in how much time(seconds) it can cover 1/4 of a mile.....
First Step:-
Create a new html file and add the following script-
CODE
<script LANGUAGE="JavaScript">
<!-- Begin
var weight, eTime;
var horsepower1, horsepower2, horsepower3, horsepower4;
var temp1, temp2, temp3, temp4;
var speed;
var finalhp1, finalhp2, finalhp3, finalhp4, finalhp5, finalhp6;
function create(form){
eTime = form.elapsedTime.value;
weight = form.vehicleWeight.value;
temp1 = eTime / 5.825;
temp1 = temp1 * temp1 * temp1;
horsepower1 = weight / temp1;
finalhp1 = roundOff(horsepower1, 2)
horsepower2 = horsepower1 * 1.3;
finalhp2 = roundOff(horsepower2, 2)
text = "<HEAD><TITLE>1/4 Method</TITLE>";
text += "</HEAD><BODY BGCOLOR=#000000 TEXT=#FFFFFF>";
text += "<font face=arial size=-1><CENTER>";
text += "Horsepower Results - 1/4 Mile Method</CENTER><P>";
text += "Your " +form.carModel.value;
text += " weighs about " +form.vehicleWeight.value+ " pounds ";
text += "and can complete a 1/4 mile in about ";
text += form.elapsedTime.value;
text += " seconds. That means that you've got about " +finalhp1;
text += " HP at the wheels, and about " + finalhp2;
text += " HP at the flywheel.</font>";
text += "<center><form><input type=button onClick='self.close()' ";
text += "value='Close Window'></form></center></font>";
resultsWindow=window.open("", "displayWindow", "toolbar=no,menubar=no,scrollbar=auto,resizable=no,width=320,height=180")
resultsWindow.document.writeln(text);
resultsWindow.document.close();
}
function input1(form) {
Ctrl = form.carModel;
if (Ctrl.value == "") {
validatePrompt (Ctrl, "Please Input a Car Model.")
return (false);
} else
return (true);
}
function input2(form) {
Ctrl = form.vehicleWeight;
if (Ctrl.value == "") {
validatePrompt (Ctrl, "Please enter Your Vehicle Weight in Pounds.")
return (false);
} else
return (true);
}
function input3(form) {
Ctrl = form.elapsedTime;
if (Ctrl.value == "") {
validatePrompt (Ctrl, "Please enter Your 1/4 mile trapspeed. You can estimate...")
return (false);
} else
return (true);
}
function runSubmit (form, button)  {
if (!input1(form)) return;
if (!input2(form)) return;
if (!input3(form)) return;
create(form);      
return;
}
function validatePrompt (Ctrl, PromptStr) {
alert (PromptStr)
Ctrl.focus();
return;
}
function roundOff(value, precision) {
value = "" + value;
precision = parseInt(precision);
var whole = "" + Math.round(value * Math.pow(10, precision));
var decPoint = whole.length - precision;
if(decPoint != 0) {
result = whole.substring(0, decPoint);
result += ".";
result += whole.substring(decPoint, whole.length);
}
else {
result = whole;
}
return result;
}
// End -->
</script>
<CENTER>
<script LANGUAGE="JavaScript">

<!-- Original:  Joel Lavarez -->
<!-- Web Site:  http://www.speed-online.com -->

<!-- Begin
var weight, eTime;
var horsepower1, horsepower2, horsepower3, horsepower4;
var temp1, temp2, temp3, temp4;
var speed;
var finalhp1, finalhp2, finalhp3, finalhp4, finalhp5, finalhp6;
function create(form){
eTime = form.elapsedTime.value;
weight = form.vehicleWeight.value;
temp1 = eTime / 5.825;
temp1 = temp1 * temp1 * temp1;
horsepower1 = weight / temp1;
finalhp1 = roundOff(horsepower1, 2)
horsepower2 = horsepower1 * 1.3;
finalhp2 = roundOff(horsepower2, 2)
text = "<HEAD><TITLE>1/4 Method</TITLE>";
text += "</HEAD><BODY BGCOLOR=#000000 TEXT=#FFFFFF>";
text += "<font face=arial size=-1><CENTER>";
text += "Horsepower Results - 1/4 Mile Method</CENTER><P>";
text += "Your " +form.carModel.value;
text += " weighs about " +form.vehicleWeight.value+ " pounds ";
text += "and can complete a 1/4 mile in about ";
text += form.elapsedTime.value;
text += " seconds. That means that you've got about " +finalhp1;
text += " HP at the wheels, and about " + finalhp2;
text += " HP at the flywheel.</font>";
text += "<center><form><input type=button onClick='self.close()' ";
text += "value='Close Window'></form></center></font>";
resultsWindow=window.open("", "displayWindow", "toolbar=no,menubar=no,scrollbar=auto,resizable=no,width=320,height=180")
resultsWindow.document.writeln(text);
resultsWindow.document.close();
}
function input1(form) {
Ctrl = form.carModel;
if (Ctrl.value == "") {
validatePrompt (Ctrl, "Please Input a Car Model.")
return (false);
} else
return (true);
}
function input2(form) {
Ctrl = form.vehicleWeight;
if (Ctrl.value == "") {
validatePrompt (Ctrl, "Please enter Your Vehicle Weight in Pounds.")
return (false);
} else
return (true);
}
function input3(form) {
Ctrl = form.elapsedTime;
if (Ctrl.value == "") {
validatePrompt (Ctrl, "Please enter Your 1/4 mile trapspeed. You can estimate...")
return (false);
} else
return (true);
}
function runSubmit (form, button)  {
if (!input1(form)) return;
if (!input2(form)) return;
if (!input3(form)) return;
create(form);      
return;
}
function validatePrompt (Ctrl, PromptStr) {
alert (PromptStr)
Ctrl.focus();
return;
}
function roundOff(value, precision) {
value = "" + value;
precision = parseInt(precision);
var whole = "" + Math.round(value * Math.pow(10, precision));
var decPoint = whole.length - precision;
if(decPoint != 0) {
result = whole.substring(0, decPoint);
result += ".";
result += whole.substring(decPoint, whole.length);
}
else {
result = whole;
}
return result;
}
// End -->
</script>

<body>

<center>
<b>Horsepower Calculator</b>
<form name="hp" method=get action="">
<center>
<table border=0>
<tr bgcolor="#909090">
<td align=right bgcolor="#3399CC"><font face="Arial, Helv"><b><font face="Courier New, Courier, mono">Car Model</font> : </b></font></td>
<td bgcolor="#319ACE"><INPUT TYPE=text NAME="carModel" SIZE=20></td>
<tr bgcolor="#909090">
<td align=right bgcolor="#FF3300"><font face="Arial, Helv"><b><font face="Courier New, Courier, mono">Vehicle Weight With Driver</font> : </b></font></td>
<td bgcolor="#FF3000"><INPUT TYPE=text NAME="vehicleWeight" SIZE=10> (<font face="Courier New, Courier, mono">in Pounds</font>)</td>
<tr bgcolor="#909090">
<td align=right bgcolor="#996699"><font face="Arial, Helv"><b><font face="Courier New, Courier, mono">Quarter Mile time</font> : </b></font></td>
<td bgcolor="#9C659C"><INPUT TYPE=text NAME="elapsedTime" SIZE=10> (<font face="Courier New, Courier, mono">in seconds</font>)</td>
</table>
<p>
</font>
<input type=button onClick="runSubmit(form)" name="HPcalc" value="Calculate Horsepower">
</form>

Thats it......If u hav any problems then pm me or send me a mail


REGARDS..... smile.gif


© 2002-2005 Flaxweb Network | Article Manager | Gimp Tutorials Library | RAD C++ Library | Free C/C++ Sourcecode |
Sites of interest : Web Design Blog | Swish Templates | Swishmax Ebook | Photoshop Templates | Gimp Tutorials | Text Forum | Make Money Online