Jump to content

Math with no javascript. I don't understand it.


crmamx

Recommended Posts

<html>
<head>
<style>
#table.my-table{
border-color: #FFCC00 #FFCC00 #FFCC00 #FFCC00; <!-- #BFBFBF #5A5A5A #5A5A5A #BFBFBF; -->
bgcolor: #FFCC00;
border-style: solid;
border-width: 10px;
text-align: left;
border-collapse: separate;
border-spacing: 2px;	
}
table.my-table tr{		
}
.my-table td{			
padding:2px 7px;		
border:1px solid;
border-color:#5A5A5A #BFBFBF #BFBFBF #5A5A5A ;
}
</style>
</head>
<body>
<FORM>
<center>
<table BORDER=4 BGCOLOR="#bfe3fe" >
 <tr>
 <td ALIGN=CENTER VALIGN=CENTER COLSPAN="7"><center><h2>Temperature Conversion Calculator</h2></center>
 </td>
 </tr>
 <tr>
 <td ALIGN=CENTER>Fahrenheit</td>
 <td ALIGN=CENTER>Celsius</td>
 <td ALIGN=CENTER>Kelvin</td>
 <td><center><INPUT TYPE="Reset" NAME="Reset" VALUE="Reset"></center></td>
 </tr>
 <tr>
 <td><center><INPUT TYPE="text" NAME="F" VALUE="" SIZE="6" MAXLENGTH="6" onchange="eval('C.value = ' + this.form.C_expr.value);eval('K.value = ' + this.form.K_expr.value)">
			 <INPUT TYPE="hidden" NAME="F_expr" VALUE="(Math.round(((212-32)/100 * C.value + 32)*100))/100;">
			 <INPUT TYPE="hidden" NAME="F_expr2" VALUE="(Math.round(((212-32)/100 *(K.value - 273) + 32)*100))/100; "></center></td>
 <td><center><INPUT TYPE="text" NAME="C" VALUE="" SIZE="6" MAXLENGTH="6" onchange="eval('F.value = ' + this.form.F_expr.value);eval('K.value = ' + this.form.K_expr.value)">
			 <INPUT TYPE="hidden" NAME="C_expr" VALUE="(Math.round((100/(212-32) * (F.value - 32))*100))/100"> <INPUT TYPE="hidden" NAME="C_expr2" VALUE="(Math.round(K.value - 273))"></center></td>
 <td><center><INPUT TYPE="text" NAME="K" VALUE="" SIZE="6" MAXLENGTH="6" onchange="eval('F.value = ' + this.form.F_expr2.value);eval('C.value = ' + this.form.C_expr2.value)">
			 <INPUT TYPE="hidden" NAME="K_expr" VALUE="(Math.round((100/(212-32) * (F.value - 32))*100))/100 + 273"></center></td>
 <td><center><INPUT TYPE="button" NAME="Reset" VALUE="Calculate"></center></td>
 </tr>
</table>
</center>
</FORM>
</body>
</html>

I was looking for a program to do length, volume, weight and temperature conversions for my web site. I found the first 3 written in Javascript. I tried to modify it to include temperature with no success. Then I discovered one for temperature and modified the look to match what I already had.

 

But I have never seen computations done with html alone. I cannot find an explanation anywhere. Everything I can find says “onchange designates a Javascript to run…”

 

Can you point me to an explanation of :

 

onchange="eval('C.value = ' + this.form.C_expr.value);eval('K.value = ' + this.form.K_expr.value)">

 

and

 

VALUE="(Math.round(((212-32)/100 * C.value + 32)*100))/100;">

 

I understand the math. But I can’t find “eval, this form, C expr.value” used with onchange. And I can’t find “Math.round” used with VALUE.

Edited by crmamx
Link to comment
Share on other sites

But I have never seen computations done with html alone. I cannot find an explanation anywhere. Everything I can find says “onchange designates a Javascript to run…”

Because it can't. HTML is purely markup. It cannot do math.

 

Can you point me to an explanation of :

 

onchange="eval('C.value = ' + this.form.C_expr.value);eval('K.value = ' + this.form.K_expr.value)">

 

and

 

VALUE="(Math.round(((212-32)/100 * C.value + 32)*100))/100;">

 

I understand the math. But I can’t find “eval, this form, C expr.value” used with onchange. And I can’t find “Math.round” used with VALUE.

 

What are you confused about? The functions you use in an onchange are irrelevant to how they work.

Link to comment
Share on other sites

Many thanks. I now have a totally new outlook on life........well, almost.

 

I can usually get the job done although I certainly am not an advanced coder. I have called functions but never realized you could execute javascript without being inside <script></script>.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.