Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I'm developing a PHP calculator, actually my question is when i click to any of the input buttons the value should display in the text box. below is the code what i have tried with, but im unable to get the resut. can any one help me in my work,so that how i can get the desired result.

What I have tried:

 HTML CODE
<div style="padding-left:40px">
        <h2> PHP Calculator</h2>
        <form method="post" action="">
            
            Enter value: <input type="text" name="value"> <br> <br> 
            <div style="padding-left: 105px">
                <input type="submit" value="9" name="button">
                <input type="submit" value="8" name="button">
                <input type="submit" value="7" name="button"> <input type="submit" value="+" name="button"> <br>
                <input type="submit" value="6" name="button">
                <input type="submit" value="5" name="button">
                <input type="submit" value="4" name="button"> <input type="submit" value="-" name="button" style="padding-left: 9px"> <br>
                <input type="submit" value="3" name="button">
                <input type="submit" value="2" name="button">
                <input type="submit" value="1" name="button"> <input type="submit" value="/" name="button" style="padding-left: 9px"> <br>
                <input type="submit" value="0" name="button" style="padding-left:33px"> 
                <input type="submit" value="." name="button" style="padding-right:9px"> <input type="submit" value="x" name="button" style="padding-left: 7px"> <br>
            </div> <br> 
                <input type="submit" value="Calculate" name="Calculator">
           
        </form>     
    </div>
   
   PHP CODE :
   <?php 
    
       if (isset($_POST["Calculate"]))
       {
           echo $_POST["button"];
       }
?>
Posted
Updated 27-Nov-22 9:01am

1 solution

give me all your code .. to help^you
 
Share this answer
 
Comments
Richard Deeming 28-Nov-22 6:06am    
Aside from the fact that the OP is unlikely to still want help with their homework 4½ years later, your comment is not a "solution" to the question. If you want to ask for more information, click the "Have a Question or Comment?" button under the question and post a comment.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900