edrew04 Posted January 3, 2009 Share Posted January 3, 2009 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., 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> Quote Link to comment https://forums.phpfreaks.com/topic/139297-phphtmlcssjavascript/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.