crmamx Posted February 15, 2013 Share Posted February 15, 2013 (edited) <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 February 15, 2013 by crmamx Quote Link to comment https://forums.phpfreaks.com/topic/274530-math-with-no-javascript-i-dont-understand-it/ Share on other sites More sharing options...
Jessica Posted February 15, 2013 Share Posted February 15, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/274530-math-with-no-javascript-i-dont-understand-it/#findComment-1412640 Share on other sites More sharing options...
crmamx Posted February 15, 2013 Author Share Posted February 15, 2013 I am only familiar with javascript calling a function and I have not defined a function. So are you saying that the code is executing javascript? What about "Value=(Math.round..........."? Is this also javascript? Quote Link to comment https://forums.phpfreaks.com/topic/274530-math-with-no-javascript-i-dont-understand-it/#findComment-1412644 Share on other sites More sharing options...
Jessica Posted February 15, 2013 Share Posted February 15, 2013 Everything inside the onchange attribute is javascript. Quote Link to comment https://forums.phpfreaks.com/topic/274530-math-with-no-javascript-i-dont-understand-it/#findComment-1412645 Share on other sites More sharing options...
crmamx Posted February 15, 2013 Author Share Posted February 15, 2013 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>. Quote Link to comment https://forums.phpfreaks.com/topic/274530-math-with-no-javascript-i-dont-understand-it/#findComment-1412663 Share on other sites More sharing options...
Jessica Posted February 15, 2013 Share Posted February 15, 2013 You really SHOULDN'T but it's possible. Quote Link to comment https://forums.phpfreaks.com/topic/274530-math-with-no-javascript-i-dont-understand-it/#findComment-1412668 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.