Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
PHP/Javascript/HTML Math help?
I'm not sure which of PHP/Javascript or HTML is easier for this task but please help.
I want to create a page, where the view can put their variables into a form and the equation will give them an answer.
(E-F) + (A+b)/2 x CD / 10000
Points for best answer!
Please give code for how to do this!
:)
6 Answers
- LDPLv 69 years agoFavorite Answer
Use JavaScript. It'll be the fastest and most efficient way of doing this.
HTML does not have math capabilities, anyway.
- 9 years ago
PHP for sure i assume for E,F,A,B and CD or C & D you want separate values. In PHP this is easy.
example:
<?php
$E = '55'; // this is the method to mannually define the value you wish to use for $E
$F = $_POST['Fvalue']; // this is getting its value from a text field with the name "Fvalue"
// and so on.. do the same for the rest
//Now for the calculation
// using echo we will display the calculation straight away
echo ('($E - $F) + ($A + $b) / 2 * $CD / 10000');
echo ('($E - $F) + ($A + $b) / 2 * ($C * $D) / 10000'); // or if C and D are separate.
?>
<input type="text" name="Fvalue"> Hope this helped
... you will have to make a submit form and tweak this code allot.. was just a rough idea of what you will have to do.
Source(s): I am a coder. Owner of Auzdesigns.tk - green meklarLv 79 years ago
Javascript is a perfectly good way to do this.
Here's the HTML:
<p>A: <input type="text" id="input_A" value="0"></p>
<p>B: <input type="text" id="input_B" value="0"></p>
<p>C: <input type="text" id="input_C" value="0"></p>
<p>D: <input type="text" id="input_D" value="0"></p>
<p>E: <input type="text" id="input_E" value="0"></p>
<p>F: <input type="text" id="input_F" value="0"></p>
<p><input type="button" value="Compute" onclick="go()"></p>
<a id="output"></a>
Here's the Javascript (with tags):
<script type="text/javascript">
function getinput(ind)
{
return( parseFloat( document.getElementById( "input_"+ind ).value ) );
}
function go()
{
var A=getinput("A");
var B=getinput("B");
var C=getinput("C");
var D=getinput("D");
var E=getinput("E");
var F=getinput("F");
var ans = ((E-F) + ((A + B) * 0.5)) * C * D * 0.0001;
document.getElementById( "output" ).innerHTML = "<p>"+ans+"</p>";
}
</script>
Since your formula didn't make the order of operations clear, I have used the most natural interpretation given the positions of the constants in the formula. Also note that Javascript performs floating-point math and the answer may not be quite precise (for instance, 0.0001 cannot be represented precisely, so a value very close to it will be used instead). It should be close enough for your purposes though.
- nicefxLv 59 years ago
HTML is not a programming language, so it can not calculate any math expression.
you need Javascript which interfaced by HTML to display a form
here is the code : http://www.learn-javascript-tutorial.com/FormValid...
- How do you think about the answers? You can sign in to vote the answer.
- Anonymous5 years ago
Eh... Neither... But i guess i'll select English. I used to love English more but excessive school made it boring. -_- however I nonetheless love writing as a passion (and hate math, even though i'm not bad at it) so i'll simply say English.
- ChristopherLv 49 years ago
PHP:
(E-F) + (A+b)/2 * (C*D) / 10000
I'm not sure if that works, try it. If it doesn't work then refine it. Research so you'll learn something.
Hope this helps :)
.
Source(s): . Web Developer http://www.newcoderslife.wordpress.com/ http://www.facebook.com/newcoderslife