Jump to content

Input boxes that apply to formula


mikebyrne

Recommended Posts

I have a form with two input boxes "n" and "m" which I want to place into the following formula

 

1-n/(n+m)

 

How do I code the php to do this?

 

my form looks like this:

 

<form>
First name:
<input type="text" name="N" />
<br />
Last name:
<input type="text" name="M" />
</form>

Link to comment
https://forums.phpfreaks.com/topic/170316-input-boxes-that-apply-to-formula/
Share on other sites

well there are multiple ways. you need to read a tutorial on how php and html forms communication:

 

http://www.tizag.com/phpT/examples/formex.php/

 

you can also use javascript and the HTML DOM to do it more dynamically

 

http://www.w3schools.com/js/js_obj_htmldom.asp

My code so far is

 

<form>
N:
<input type="text" name="N" />
<br />
M:
<input type="text" name="M" />
<INPUT type="submit" name="mysubmit" value="Click!">
</form>
<?php
$n = $_POST['n'];
$m = $_POST['m'];

$answer = 1-$n/(n+m);
?>

 

I know im not a million miles away

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.