mikebyrne Posted August 14, 2009 Share Posted August 14, 2009 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 More sharing options...
mikesta707 Posted August 14, 2009 Share Posted August 14, 2009 $n = $_POST['n']; $m = $_POST['m']; $answer = 1-$n/(n+m); ? Link to comment https://forums.phpfreaks.com/topic/170316-input-boxes-that-apply-to-formula/#findComment-898436 Share on other sites More sharing options...
mikebyrne Posted August 14, 2009 Author Share Posted August 14, 2009 Thanks for your quick reply How could I code a submit button so that when the user presses the button it runs the formula?? Link to comment https://forums.phpfreaks.com/topic/170316-input-boxes-that-apply-to-formula/#findComment-898440 Share on other sites More sharing options...
mikesta707 Posted August 14, 2009 Share Posted August 14, 2009 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 Link to comment https://forums.phpfreaks.com/topic/170316-input-boxes-that-apply-to-formula/#findComment-898442 Share on other sites More sharing options...
mikebyrne Posted August 14, 2009 Author Share Posted August 14, 2009 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 Link to comment https://forums.phpfreaks.com/topic/170316-input-boxes-that-apply-to-formula/#findComment-898447 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.