Search the web
Sign In
New User? Sign Up
phpexperts
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Want your group to be featured on the Yahoo! Groups website? Add a group photo to Flickr.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
php help on basic calculator   Message List  
Reply | Forward Message #10795 of 13257 |
i had made a calculator form in html/css & javascipt but i need a
little help for it to work by embedding php on it.it is indicated in
our project that it is compulsary to use pure php codes on the
mathematical operations, please help me. here is my code to be
embedded with php:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-
transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Machine Problem #1: Calculator</title>
<script language="javscript" type="text/javascript">
<!--
function addbool(){
calc.txtInput.value = '-'+calc.txtInput.value;
}
function resetform(){
calc.bool.disabled = 0;
calc.decimal.disabled = 0;
calc.add.disabled = 0;
calc.subtract.disabled = 0;
calc.multiply.disabled = 0;
calc.divide.disabled = 0;
}
function passval(){
calc.txtStored.value = calc.txtInput.value;
calc.txtInput.value = "";
}
function disablebtn(){
calc.divide.disabled = 1;
calc.multiply.disabled = 1;
calc.subtract.disabled = 1;
calc.add.disabled = 1;
calc.decimal.disabled = 0;
}
//-->
</script>
<style type="text/css">
input.field{
width:100%;
height:30px;
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:18px;
text-align:right;
}
.btn{
width:40px;
height:40px;
}
.btn0{
width:100%;
height:40px;
}
</style>

</head>
<body>
<form id="form1" name="calc" method="get" action="">
<table width="100%" border="0">
<tr>
<td align="center" valign="middle"><table width="180"
border="0">
<tr>
<td colspan="4" align="center" valign="middle"><input
name="txtInput" type="text" class="field" id="txtInput"
style="width:100%;" maxlength="12"/>
<input type="hidden" name="txtStored" id="txtStored"/>
<input type="hidden" name="txtTypeof" id="txtTypeof"/>
</td>
</tr>
<tr>
<td align="center" valign="middle"><label>
<input name="7" type="button" class="btn" id="7"
value="7" OnClick="calc.txtInput.value += '7'"/>
</label></td>
<td align="center" valign="middle"><input name="8"
type="button" class="btn" id="8" value="8"
OnClick="calc.txtInput.value += '8'"/></td>
<td align="center" valign="middle"><input name="9"
type="button" class="btn" id="9" value="9"
OnClick="calc.txtInput.value += '9'"/></td>
<td align="center" valign="middle"><input name="divide"
type="button" class="btn" id="divide" value="/" OnClick="disablebtn
(); passval(); calc.txtTypeof.value = 'divide';"/></td>
</tr>
<tr>
<td align="center" valign="middle"><input name="4"
type="button" class="btn" id="4" value="4"
OnClick="calc.txtInput.value += '4'"/></td>
<td align="center" valign="middle"><input name="5"
type="button" class="btn" id="5" value="5"
OnClick="calc.txtInput.value += '5'"/></td>
<td align="center" valign="middle"><input name="6"
type="button" class="btn" id="6" value="6"
OnClick="calc.txtInput.value += '6'"/></td>
<td align="center" valign="middle"><input
name="multiply" type="button" class="btn" id="multiply" value="*"
OnClick="disablebtn(); passval(); calc.txtTypeof.value
= 'multiply';"//></td>
</tr>
<tr>
<td align="center" valign="middle"><input name="3"
type="button" class="btn" id="3" value="1"
OnClick="calc.txtInput.value += '1'"/></td>
<td align="center" valign="middle"><input name="2"
type="button" class="btn" id="2" value="2"
OnClick="calc.txtInput.value += '2'"/></td>
<td align="center" valign="middle"><input name="1"
type="button" class="btn" id="1" value="3"
OnClick="calc.txtInput.value += '3'"/></td>
<td align="center" valign="middle"><input
name="subtract" type="button" class="btn" id="subtract" value="-"
OnClick="disablebtn(); passval(); calc.txtTypeof.value
= 'subtract';"//></td>
</tr>
<tr>
<td align="center" valign="middle"><input name="0"
type="button" class="btn" id="0" value="0"
OnClick="calc.txtInput.value += '0'"/></td>
<td align="center" valign="middle"><input name="bool"
type="button" class="btn" id="bool" value="+/-" OnClick="addbool
();this.disabled=1;"/></td>
<td align="center" valign="middle"><input name="decimal"
type="button" class="btn" id="decimal" value="."
OnClick="this.disabled=1; calc.txtInput.value += '.'"/></td>
<td align="center" valign="middle"><input name="add"
type="button" class="btn" id="add" value="+" OnClick="disablebtn();
passval(); calc.txtTypeof.value = 'add';"//></td>
</tr>
<tr>
<td colspan="2" align="center" valign="middle"><input
name="reset" type="reset" class="btn0" id="reset" value="CE"/></td>
<td colspan="2" align="center" valign="middle"><input
name="equal" type="submit" class="btn0" id="equal" value="=" /></td>
</tr>
</table>
<br /></td>
</tr>
</table>
</form>
</body>
</html>





Mon Jan 5, 2009 2:53 am

edrew04
Online Now Online Now
Send Email Send Email

Forward
Message #10795 of 13257 |
Expand Messages Author Sort by Date

i had made a calculator form in html/css & javascipt but i need a little help for it to work by embedding php on it.it is indicated in our project that it is...
edrew04
Online Now Send Email
Jan 5, 2009
11:35 am

Hi, This sounds like an assignment for school, and thus a learning experience, so I don't particularly feel comfortable just giving you the answers. When you...
Joe Forsythe
jforsythe@...
Send Email
Jan 5, 2009
1:33 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help