SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    I LOVE THIS SITE ! ! ! DougD's Avatar
    Join Date
    May 2000
    Location
    San Diego, CA
    Posts
    463
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Anyone know where to find a simple calculator script. One that looks like a caculator (adds, subtracts, multiplies, divides). I don't need any other functions.

    Any suggestions would be appreciated!

    Thanks,

    Doug

  2. #2
    SitePoint Addict zoordaan's Avatar
    Join Date
    Feb 2001
    Location
    NYC/Texas
    Posts
    348
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well it doesn't look like a calulator but you could modify it. I don't remember where I saw this but here it is:

    Code:
    <?
    
    ECHO "<BR>"; 
    
    IF(isset($a)){ /* they hit the submit button on the form */ 
    ECHO "The first number you entered is $a<BR>"; 
    ECHO "The second number you entered is $b<BR>"; 
    ECHO "op=$op<BR>"; 
    If($op=="m"){ $answer=$a-$b;} 
    If($op=="p"){ $answer=$a+$b;} 
    If($op=="t"){ $answer=$a*$b;} 
    If($op=="d"){ $answer=$a/$b;} 
    ECHO "answer=$answer"; 
    }
    
    ?>
    <FORM ACTION='<? ECHO $SCRIPT_NAME ?>' METHOD=post>
    <INPUT TYPE="text" NAME="a"><P>
    <INPUT TYPE="radio" NAME="op" VALUE="p">Plus<BR>
    <INPUT TYPE="radio" NAME="op" VALUE="m">Minus<BR>
    <INPUT TYPE="radio" NAME="op" VALUE="t">Times<BR>
    <INPUT TYPE="radio" NAME="op" VALUE="d">Divided By<BR>
    <INPUT TYPE="text" NAME="b">
    <INPUT TYPE="submit" NAME="Submit" VALUE=" = ">
    </FORM>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •