| View previous topic :: View next topic |
| Author |
Message |
bestbuildpc I might as well work here


Joined: Nov 16, 2009 Posts: 100
|
Posted: Sat Jul 07, 2012 5:36 pm Post subject: Calcalator block but not validate it. |
|
|
Bobby, long time ago I made a calculator block but I notice now it is not validate it. Is there any program to validate files when they are .php?
This is a very simple block which doesnt require flash.
Code:<?php
if ( !defined('BLOCK_FILE') ) {
Header('Location: ../index.php');
die();
}
$content = "<center><table border=0 width=130 cellspacing=0 cellpadding=0><tr><td>\n"
."<table border=0 WIDTH=\"100%\" cellspacing=1 cellpadding=3>\n"
."<tr><td style=\"background-color:#eeeeee;\">\n"
."<script language=\"JavaScript\">\n"
."<!--\n"
."r = new Array(2)\n"
."function setStartState() {\n"
."\tstate = \"start\"\n"
."\tr[0] = \"0\"\n"
."\tr[1] = \"0\"\n"
."\toperator = \"\"\n"
."\tix = 0\n"
."}\n"
."function addDigit(n) {\n"
."\tif(state==\"gettingInteger\" || state==\"gettingFloat\")\n"
."\tr[ix]=appendDigit(r[ix],n)\n"
."\telse {\n"
."\t\tr[ix] = \"\"+n\n"
."\t\tstate = \"gettingInteger\"\n"
."\t}\n"
."\tdisplay(r[ix])\n"
."}\n"
."function appendDigit(n1,n2) {\n"
."\tif(n1==\"0\") return \"\"+n2\n"
."\tvar s = \"\"\n"
."\ts+=n1\n"
."\ts+=n2\n"
."\treturn s\n"
."}\n"
."function display(s) {\n"
."\tdocument.calculator.total.value=s\n"
."}\n"
."function addDecimalPoint() {\n"
."\tif(state!=\"gettingFloat\") {\n"
."\t\tdecimal=true\n"
."\t\tr[ix]+=\".\"\n"
."\t\tif(state==\"haveOperand\" || state==\"getOperand2\") r[ix]=\"0.\"\n"
."\t\tstate=\"gettingFloat\"\n"
."\t\tdisplay(r[ix])\n"
."\t}\n"
."}\n"
."function clearDisplay() {\n"
."\tsetStartState()\n"
."\tdisplay(r[0])\n"
."}\n"
."function changeSign() {\n"
."\tif(r[ix].charAt(0)==\"-\") r[ix]=r[ix].substring(1,r[ix].length)\n"
."\telse if(parseFloat(r[ix])!=0) r[ix]=\"-\"+r[ix]\n"
."\tdisplay(r[ix])\n"
."}\n"
."function calc() {\n"
."\tif(state==\"gettingInteger\" || state==\"gettingFloat\" || state==\"haveOperand\") {\n"
."\t\tif(ix==1) {\n"
."\t\t\tr[0]=calculateOperation(operator,r[0],r[1])\n"
."\t\t\tix=0\n"
."\t\t}\n"
."\t}\n"
."\telse if(state==\"getOperand2\") {\n"
."\t\tr[0]=calculateOperation(operator,r[0],r[0])\n"
."\t\tix=0\n"
."\t}\n"
."\tstate=\"haveOperand\"\n"
."\tdecimal=false\n"
."\tdisplay(r[ix])\n"
."}\n"
."function calculateOperation(op,x,y) {\n"
."\tvar result=\"\"\n"
."\tif(op==\"+\") {\n"
."\t\tresult=\"\"+(parseFloat(x)+parseFloat(y))\n"
."\t}\n"
."\telse if(op==\"-\") {\n"
."\t\tresult=\"\"+(parseFloat(x)-parseFloat(y))\n"
."\t}\n"
."\telse if(op==\"*\") {\n"
."\t\tresult=\"\"+(parseFloat(x)*parseFloat(y))\n"
."\t}\n"
."\telse if(op==\"/\") {\n"
."\t\tif(parseFloat(y)==0) {\n"
."\t\t\talert(\"".("ERROR!")."\")\n"
."\t\t\tresult=0\n"
."\t\t}\n"
."\t\telse result=\"\"+(parseFloat(x)/parseFloat(y))\n"
."\t}\n"
."\treturn result\n"
."}\n"
."function performOp(op) {\n"
."\tif(state==\"start\") {\n"
."\t\t++ix\n"
."\t\toperator=op\n"
."\t}\n"
."\telse if(state==\"gettingInteger\" || state==\"gettingFloat\" || state==\"haveOperand\") {\n"
."\t\tif(ix==0) {\n"
."\t\t\t++ix\n"
."\t\t\toperator=op\n"
."\t\t}\n"
."\t\telse {\n"
."\t\t\tr[0]=calculateOperation(operator,r[0],r[1])\n"
."\t\t\tdisplay(r[0])\n"
."\t\t\toperator=op\n"
."\t\t}\n"
."\t}\n"
."\tstate=\"getOperand2\"\n"
."\tdecimal=false\n"
."}\n"
."// -->\n"
."</script>\n"
."<script language=\"JavaScript\">\n"
."<!--\n"
."setStartState()\n"
."// -->\n"
."</script>\n"
."<form name=\"calculator\">\n"
."<div align=\"center\"><center><table border=\"0\">\n"
."<TBODY><tr>\n"
."<td align=\"center\" colspan=\"3\"><input type=\"text\" size=\"20\" name=\"total\" value=\"0\"></td>\n"
."</tr><tr>\n"
."<td align=\"center\"><input type=\"button\" name=\"n1\" value=\" 1 \" onclick=\"addDigit(1)\" style=\"WIDTH: 35px\" width=\"35\"></td>\n"
."<td align=\"center\"><input type=\"button\" name=\"n2\" value=\" 2 \" onclick=\"addDigit(2)\" style=\"WIDTH: 35px\" width=\"35\"></td>\n"
."<td align=\"center\"><input type=\"button\" name=\"n3\" value=\" 3 \" onclick=\"addDigit(3)\" style=\"WIDTH: 35px\" width=\"35\"></td>\n"
."</tr><tr>\n"
."<td align=\"center\"><input type=\"button\" name=\"n4\" value=\" 4 \" onclick=\"addDigit(4)\" style=\"WIDTH: 35px\" width=\"35\"></td>\n"
."<td align=\"center\"><input type=\"button\" name=\"n5\" value=\" 5 \" onclick=\"addDigit(5)\" style=\"WIDTH: 35px\" width=\"35\"></td>\n"
."<td align=\"center\"><input type=\"button\" name=\"n6\" value=\" 6 \" onclick=\"addDigit(6)\" style=\"WIDTH: 35px\" width=\"35\"></td>\n"
."</tr><tr>\n"
."<td align=\"center\"><input type=\"button\" name=\"n7\" value=\" 7 \" onclick=\"addDigit(7)\" style=\"WIDTH: 35px\" width=\"35\"></td>\n"
."<td align=\"center\"><input type=\"button\" name=\"n8\" value=\" 8 \" onclick=\"addDigit(8)\" style=\"WIDTH: 35px\" width=\"35\"></td>\n"
."<td align=\"center\"><input type=\"button\" name=\"n9\" value=\" 9 \" onclick=\"addDigit(9)\" style=\"WIDTH: 35px\" width=\"35\"></td>\n"
."</tr><tr>\n"
."<td align=\"center\"><input type=\"button\" name=\"decimal\" value=\" . \" onclick=\"addDecimalPoint()\" style=\"WIDTH: 35px\" width=\"35\"></td>\n"
."<td align=\"center\"><input type=\"button\" name=\"n0\" value=\" 0 \" onclick=\"addDigit(0)\" style=\"WIDTH: 35px\" width=\"35\"></td>\n"
."<td align=\"center\"><input type=\"button\" name=\"plus\" value=\" + \" onclick=\"performOp('+')\" style=\"WIDTH: 35px\" width=\"35\"></td>\n"
."</tr><tr>\n"
."<td align=\"center\"><input type=\"button\" name=\"minus\" value=\" - \" onclick=\"performOp('-')\" style=\"WIDTH: 35px\" width=\"35\"></td>\n"
."<td align=\"center\"><input type=\"button\" name=\"multiply\" value=\" x \" onclick=\"performOp('*')\" style=\"WIDTH: 35px\" width=\"35\"></td>\n"
."<td align=\"center\"><input type=\"button\" name=\"divide\" value=\" / \" onclick=\"performOp('/')\" style=\"WIDTH: 35px\" width=\"35\"></td>\n"
."</tr><tr>\n"
."<td align=\"center\"><input type=\"button\" name=\"equals\" value=\" = \" onclick=\"calc()\" style=\"WIDTH: 35px\" width=\"35\"></td>\n"
."<td align=\"center\"><input type=\"button\" name=\"sign\" value=\" +/- \" onclick=\"changeSign()\" style=\"WIDTH: 35px\" width=\"35\"></td>\n"
."<td align=\"center\"><input type=\"button\" name=\"clearField\" value=\" C \" onclick=\"clearDisplay()\" style=\"WIDTH: 35px\" width=\"35\"></td>\n"
."</tr></TBODY></table>\n"
."</center></div></td></tr></table></form></td></tr></table>\n";
|
I love this simple calculator but I want to validate it. |
|
| Back to top |
|
 |
bobby Site Admin


Joined: Jan 20, 2009 Posts: 779 Location: North Carolina
|
|
| Back to top |
|
 |
bestbuildpc I might as well work here


Joined: Nov 16, 2009 Posts: 100
|
|
| Back to top |
|
 |
bestbuildpc I might as well work here


Joined: Nov 16, 2009 Posts: 100
|
Posted: Sun Jul 08, 2012 9:02 am Post subject: |
|
|
Please, help me validate this block. I did some modifications but I still have errors and warnings.
Code:<?php
if ( !defined('BLOCK_FILE') ) {
Header('Location: ../index.php');
die();
}
$content = "<center><table border=0 width=130 cellspacing=0 cellpadding=0><tr><td>\n"
."<table border=0 WIDTH=\"100%\" cellspacing=1 cellpadding=3>\n"
."<tr><td style=\"background-color:#eeeeee;\">\n"
."<script language=\"JavaScript\">\n"
."<!--\n"
."r = new Array(2)\n"
."function setStartState() {\n"
."\tstate = \"start\"\n"
."\tr[0] = \"0\"\n"
."\tr[1] = \"0\"\n"
."\toperator = \"\"\n"
."\tix = 0\n"
."}\n"
."function addDigit(n) {\n"
."\tif(state==\"gettingInteger\" || state==\"gettingFloat\")\n"
."\tr[ix]=appendDigit(r[ix],n)\n"
."\telse {\n"
."\t\tr[ix] = \"\"+n\n"
."\t\tstate = \"gettingInteger\"\n"
."\t}\n"
."\tdisplay(r[ix])\n"
."}\n"
."function appendDigit(n1,n2) {\n"
."\tif(n1==\"0\") return \"\"+n2\n"
."\tvar s = \"\"\n"
."\ts+=n1\n"
."\ts+=n2\n"
."\treturn s\n"
."}\n"
."function display(s) {\n"
."\tdocument.calculator.total.value=s\n"
."}\n"
."function addDecimalPoint() {\n"
."\tif(state!=\"gettingFloat\") {\n"
."\t\tdecimal=true\n"
."\t\tr[ix]+=\".\"\n"
."\t\tif(state==\"haveOperand\" || state==\"getOperand2\") r[ix]=\"0.\"\n"
."\t\tstate=\"gettingFloat\"\n"
."\t\tdisplay(r[ix])\n"
."\t}\n"
."}\n"
."function clearDisplay() {\n"
."\tsetStartState()\n"
."\tdisplay(r[0])\n"
."}\n"
."function changeSign() {\n"
."\tif(r[ix].charAt(0)==\"-\") r[ix]=r[ix].substring(1,r[ix].length)\n"
."\telse if(parseFloat(r[ix])!=0) r[ix]=\"-\"+r[ix]\n"
."\tdisplay(r[ix])\n"
."}\n"
."function calc() {\n"
."\tif(state==\"gettingInteger\" || state==\"gettingFloat\" || state==\"haveOperand\") {\n"
."\t\tif(ix==1) {\n"
."\t\t\tr[0]=calculateOperation(operator,r[0],r[1])\n"
."\t\t\tix=0\n"
."\t\t}\n"
."\t}\n"
."\telse if(state==\"getOperand2\") {\n"
."\t\tr[0]=calculateOperation(operator,r[0],r[0])\n"
."\t\tix=0\n"
."\t}\n"
."\tstate=\"haveOperand\"\n"
."\tdecimal=false\n"
."\tdisplay(r[ix])\n"
."}\n"
."function calculateOperation(op,x,y) {\n"
."\tvar result=\"\"\n"
."\tif(op==\"+\") {\n"
."\t\tresult=\"\"+(parseFloat(x)+parseFloat(y))\n"
."\t}\n"
."\telse if(op==\"-\") {\n"
."\t\tresult=\"\"+(parseFloat(x)-parseFloat(y))\n"
."\t}\n"
."\telse if(op==\"*\") {\n"
."\t\tresult=\"\"+(parseFloat(x)*parseFloat(y))\n"
."\t}\n"
."\telse if(op==\"/\") {\n"
."\t\tif(parseFloat(y)==0) {\n"
."\t\t\talert(\"".("ERROR!")."\")\n"
."\t\t\tresult=0\n"
."\t\t}\n"
."\t\telse result=\"\"+(parseFloat(x)/parseFloat(y))\n"
."\t}\n"
."\treturn result\n"
."}\n"
."function performOp(op) {\n"
."\tif(state==\"start\") {\n"
."\t\t++ix\n"
."\t\toperator=op\n"
."\t}\n"
."\telse if(state==\"gettingInteger\" || state==\"gettingFloat\" || state==\"haveOperand\") {\n"
."\t\tif(ix==0) {\n"
."\t\t\t++ix\n"
."\t\t\toperator=op\n"
."\t\t}\n"
."\t\telse {\n"
."\t\t\tr[0]=calculateOperation(operator,r[0],r[1])\n"
."\t\t\tdisplay(r[0])\n"
."\t\t\toperator=op\n"
."\t\t}\n"
."\t}\n"
."\tstate=\"getOperand2\"\n"
."\tdecimal=false\n"
."}\n"
."// -->\n"
."</script>\n"
."<script language=\"JavaScript\">\n"
."<!--\n"
."setStartState()\n"
."// -->\n"
."</script>\n"
."<form name=\"calculator\">\n"
."<div style=\"text-align:right\" /><table border=\"0\">\n"
."<TBODY><tr>\n"
."<td align=\"center\" colspan=\"3\" /><input type=\"text\" size=\"20\" name=\"total\" value=\"0\" /></td>\n"
."</tr><tr>\n"
."<td align=\"center\"><input type=\"button\" name=\"n1\" value=\" 1 \" onclick=\"addDigit(1)\" style=\"WIDTH: 35px\" width=\"35\" /></td>\n"
."<td align=\"center\"><input type=\"button\" name=\"n2\" value=\" 2 \" onclick=\"addDigit(2)\" style=\"WIDTH: 35px\" width=\"35\" /></td>\n"
."<td align=\"center\"><input type=\"button\" name=\"n3\" value=\" 3 \" onclick=\"addDigit(3)\" style=\"WIDTH: 35px\" width=\"35\" /></td>\n"
."</tr><tr>\n"
."<td align=\"center\"><input type=\"button\" name=\"n4\" value=\" 4 \" onclick=\"addDigit(4)\" style=\"WIDTH: 35px\" width=\"35\" /></td>\n"
."<td align=\"center\"><input type=\"button\" name=\"n5\" value=\" 5 \" onclick=\"addDigit(5)\" style=\"WIDTH: 35px\" width=\"35\" /></td>\n"
."<td align=\"center\"><input type=\"button\" name=\"n6\" value=\" 6 \" onclick=\"addDigit(6)\" style=\"WIDTH: 35px\" width=\"35\" /></td>\n"
."</tr><tr>\n"
."<td align=\"center\"><input type=\"button\" name=\"n7\" value=\" 7 \" onclick=\"addDigit(7)\" style=\"WIDTH: 35px\" width=\"35\" /></td>\n"
."<td align=\"center\"><input type=\"button\" name=\"n8\" value=\" 8 \" onclick=\"addDigit(8)\" style=\"WIDTH: 35px\" width=\"35\" /></td>\n"
."<td align=\"center\"><input type=\"button\" name=\"n9\" value=\" 9 \" onclick=\"addDigit(9)\" style=\"WIDTH: 35px\" width=\"35\" /></td>\n"
."</tr><tr>\n"
."<td align=\"center\"><input type=\"button\" name=\"decimal\" value=\" . \" onclick=\"addDecimalPoint()\" style=\"WIDTH: 35px\" width=\"35\" /></td>\n"
."<td align=\"center\"><input type=\"button\" name=\"n0\" value=\" 0 \" onclick=\"addDigit(0)\" style=\"WIDTH: 35px\" width=\"35\" /></td>\n"
."<td align=\"center\"><input type=\"button\" name=\"plus\" value=\" + \" onclick=\"performOp('+')\" style=\"WIDTH: 35px\" width=\"35\" /></td>\n"
."</tr><tr>\n"
."<td align=\"center\"><input type=\"button\" name=\"minus\" value=\" - \" onclick=\"performOp('-')\" style=\"WIDTH: 35px\" width=\"35\" /></td>\n"
."<td align=\"center\"><input type=\"button\" name=\"multiply\" value=\" x \" onclick=\"performOp('*')\" style=\"WIDTH: 35px\" width=\"35\" /></td>\n"
."<td align=\"center\"><input type=\"button\" name=\"divide\" value=\" / \" onclick=\"performOp('/')\" style=\"WIDTH: 35px\" width=\"35\" /></td>\n"
."</tr><tr>\n"
."<td align=\"center\"><input type=\"button\" name=\"equals\" value=\" = \" onclick=\"calc()\" style=\"WIDTH: 35px\" width=\"35\" /></td>\n"
."<td align=\"center\"><input type=\"button\" name=\"sign\" value=\" +/- \" onclick=\"changeSign()\" style=\"WIDTH: 35px\" width=\"35\" /></td>\n"
."<td align=\"center\"><input type=\"button\" name=\"clearField\" value=\" C \" onclick=\"clearDisplay()\" style=\"WIDTH: 35px\" width=\"35\" /></td>\n"
."</tr></TBODY></table>\n"
."</center></div></div></td></tr></table></form></td></tr></table>\n";
$content .= "<center><a href=\"http://www.bestbuildpc.org\" /><i>BestBuildPC</i></a>";
?>
|
|
|
| Back to top |
|
 |
bobby Site Admin


Joined: Jan 20, 2009 Posts: 779 Location: North Carolina
|
|
| Back to top |
|
 |
bobby Site Admin


Joined: Jan 20, 2009 Posts: 779 Location: North Carolina
|
Posted: Sun Jul 08, 2012 1:32 pm Post subject: |
|
|
php Code:<?php
if ( !defined('BLOCK_FILE') ) {
Header('Location: ../index.php');
die();
}
$content = "<center><table border=\"0\" width=\"130\" cellspacing=\"0\" cellpadding=\"0\"><tr><td>\n"
."<table border=\"0\" width=\"100%\" cellspacing=\"1\" cellpadding=\"3\">\n"
."<tr><td style=\"background-color:#eeeeee;\">\n"
."<script type=\"text/javascript\">\n"
."<!--\n"
."r = new Array(2)\n"
."function setStartState() {\n"
."\tstate = \"start\"\n"
."\tr[0] = \"0\"\n"
."\tr[1] = \"0\"\n"
."\toperator = \"\"\n"
."\tix = 0\n"
."}\n"
."function addDigit(n) {\n"
."\tif(state==\"gettingInteger\" || state==\"gettingFloat\")\n"
."\tr[ix]=appendDigit(r[ix],n)\n"
."\telse {\n"
."\t\tr[ix] = \"\"+n\n"
."\t\tstate = \"gettingInteger\"\n"
."\t}\n"
."\tdisplay(r[ix])\n"
."}\n"
."function appendDigit(n1,n2) {\n"
."\tif(n1==\"0\") return \"\"+n2\n"
."\tvar s = \"\"\n"
."\ts+=n1\n"
."\ts+=n2\n"
."\treturn s\n"
."}\n"
."function display(s) {\n"
."\tdocument.calculator.total.value=s\n"
."}\n"
."function addDecimalPoint() {\n"
."\tif(state!=\"gettingFloat\") {\n"
."\t\tdecimal=true\n"
."\t\tr[ix]+=\".\"\n"
."\t\tif(state==\"haveOperand\" || state==\"getOperand2\") r[ix]=\"0.\"\n"
."\t\tstate=\"gettingFloat\"\n"
."\t\tdisplay(r[ix])\n"
."\t}\n"
."}\n"
."function clearDisplay() {\n"
."\tsetStartState()\n"
."\tdisplay(r[0])\n"
."}\n"
."function changeSign() {\n"
."\tif(r[ix].charAt(0)==\"-\") r[ix]=r[ix].substring(1,r[ix].length)\n"
."\telse if(parseFloat(r[ix])!=0) r[ix]=\"-\"+r[ix]\n"
."\tdisplay(r[ix])\n"
."}\n"
."function calc() {\n"
."\tif(state==\"gettingInteger\" || state==\"gettingFloat\" || state==\"haveOperand\") {\n"
."\t\tif(ix==1) {\n"
."\t\t\tr[0]=calculateOperation(operator,r[0],r[1])\n"
."\t\t\tix=0\n"
."\t\t}\n"
."\t}\n"
."\telse if(state==\"getOperand2\") {\n"
."\t\tr[0]=calculateOperation(operator,r[0],r[0])\n"
."\t\tix=0\n"
."\t}\n"
."\tstate=\"haveOperand\"\n"
."\tdecimal=false\n"
."\tdisplay(r[ix])\n"
."}\n"
."function calculateOperation(op,x,y) {\n"
."\tvar result=\"\"\n"
."\tif(op==\"+\") {\n"
."\t\tresult=\"\"+(parseFloat(x)+parseFloat(y))\n"
."\t}\n"
."\telse if(op==\"-\") {\n"
."\t\tresult=\"\"+(parseFloat(x)-parseFloat(y))\n"
."\t}\n"
."\telse if(op==\"*\") {\n"
."\t\tresult=\"\"+(parseFloat(x)*parseFloat(y))\n"
."\t}\n"
."\telse if(op==\"/\") {\n"
."\t\tif(parseFloat(y)==0) {\n"
."\t\t\talert(\"".("ERROR!")."\")\n"
."\t\t\tresult=0\n"
."\t\t}\n"
."\t\telse result=\"\"+(parseFloat(x)/parseFloat(y))\n"
."\t}\n"
."\treturn result\n"
."}\n"
."function performOp(op) {\n"
."\tif(state==\"start\") {\n"
."\t\t++ix\n"
."\t\toperator=op\n"
."\t}\n"
."\telse if(state==\"gettingInteger\" || state==\"gettingFloat\" || state==\"haveOperand\") {\n"
."\t\tif(ix==0) {\n"
."\t\t\t++ix\n"
."\t\t\toperator=op\n"
."\t\t}\n"
."\t\telse {\n"
."\t\t\tr[0]=calculateOperation(operator,r[0],r[1])\n"
."\t\t\tdisplay(r[0])\n"
."\t\t\toperator=op\n"
."\t\t}\n"
."\t}\n"
."\tstate=\"getOperand2\"\n"
."\tdecimal=false\n"
."}\n"
."// -->\n"
."</script>\n"
."<script type=\"text/javascript\">\n"
."<!--\n"
."setStartState()\n"
."// -->\n"
."</script>\n"
."<form name=\"calculator\" action=\"\">\n"
."<table style=\"text-align:right\" border=\"0\">\n"
."<tr>\n"
."<td align=\"center\" colspan=\"3\"><input type=\"text\" size=\"20\" name=\"total\" value=\"0\" /></td>\n"
."</tr><tr>\n"
."<td align=\"center\"><input type=\"button\" name=\"n1\" value=\" 1 \" onclick=\"addDigit(1)\" style=\"width: 35px\" /></td>\n"
."<td align=\"center\"><input type=\"button\" name=\"n2\" value=\" 2 \" onclick=\"addDigit(2)\" style=\"width: 35px\" /></td>\n"
."<td align=\"center\"><input type=\"button\" name=\"n3\" value=\" 3 \" onclick=\"addDigit(3)\" style=\"width: 35px\" /></td>\n"
."</tr><tr>\n"
."<td align=\"center\"><input type=\"button\" name=\"n4\" value=\" 4 \" onclick=\"addDigit(4)\" style=\"width: 35px\" /></td>\n"
."<td align=\"center\"><input type=\"button\" name=\"n5\" value=\" 5 \" onclick=\"addDigit(5)\" style=\"width: 35px\" /></td>\n"
."<td align=\"center\"><input type=\"button\" name=\"n6\" value=\" 6 \" onclick=\"addDigit(6)\" style=\"width: 35px\" /></td>\n"
."</tr><tr>\n"
."<td align=\"center\"><input type=\"button\" name=\"n7\" value=\" 7 \" onclick=\"addDigit(7)\" style=\"width: 35px\" /></td>\n"
."<td align=\"center\"><input type=\"button\" name=\"n8\" value=\" 8 \" onclick=\"addDigit(8)\" style=\"width: 35px\" /></td>\n"
."<td align=\"center\"><input type=\"button\" name=\"n9\" value=\" 9 \" onclick=\"addDigit(9)\" style=\"width: 35px\" /></td>\n"
."</tr><tr>\n"
."<td align=\"center\"><input type=\"button\" name=\"decimal\" value=\" . \" onclick=\"addDecimalPoint()\" style=\"width: 35px\" /></td>\n"
."<td align=\"center\"><input type=\"button\" name=\"n0\" value=\" 0 \" onclick=\"addDigit(0)\" style=\"width: 35px\" /></td>\n"
."<td align=\"center\"><input type=\"button\" name=\"plus\" value=\" + \" onclick=\"performOp('+')\" style=\"width: 35px\" /></td>\n"
."</tr><tr>\n"
."<td align=\"center\"><input type=\"button\" name=\"minus\" value=\" - \" onclick=\"performOp('-')\" style=\"width: 35px\" /></td>\n"
."<td align=\"center\"><input type=\"button\" name=\"multiply\" value=\" x \" onclick=\"performOp('*')\" style=\"width: 35px\" /></td>\n"
."<td align=\"center\"><input type=\"button\" name=\"divide\" value=\" / \" onclick=\"performOp('/')\" style=\"width: 35px\" /></td>\n"
."</tr><tr>\n"
."<td align=\"center\"><input type=\"button\" name=\"equals\" value=\" = \" onclick=\"calc()\" style=\"width: 35px\" /></td>\n"
."<td align=\"center\"><input type=\"button\" name=\"sign\" value=\" +/- \" onclick=\"changeSign()\" style=\"width: 35px\" /></td>\n"
."<td align=\"center\"><input type=\"button\" name=\"clearField\" value=\" C \" onclick=\"clearDisplay()\" style=\"width: 35px\" /></td>\n"
."</tr></table>\n"
."</form></td></tr></table></td></tr></table></center>\n";
?>
|
_________________ Tricked Out News |
|
| Back to top |
|
 |
bestbuildpc I might as well work here


Joined: Nov 16, 2009 Posts: 100
|
Posted: Mon Jul 09, 2012 3:45 am Post subject: |
|
|
Buddy, this is my problem and I would like to know where u learned to validate html when it is already converted to php. This is what I don't understand. I am going to compare my old module with this one in order to learn the validation. it is finally validated, Im so happy.
This is the original old block. That is why we need to keep on updates good stuff and make new things if it is possible. Take a look, LOL
THE OLD ONE
Code:<?php
if (eregi("block-Calculadora.php",$PHP_SELF)) {
Header("Location: index.php");
die();
}
$content = "<center><table border=0 width=130 cellspacing=0 cellpadding=0><tr><td>\n"
."<table border=0 WIDTH=\"100%\" cellspacing=1 cellpadding=3>\n"
."<tr><td style=\"background-color:#eeeeee;\">\n"
."<script language=\"JavaScript\">\n"
."<!--\n"
."r = new Array(2)\n"
."function setStartState() {\n"
."\tstate = \"start\"\n"
."\tr[0] = \"0\"\n"
."\tr[1] = \"0\"\n"
."\toperator = \"\"\n"
."\tix = 0\n"
."}\n"
."function addDigit(n) {\n"
."\tif(state==\"gettingInteger\" || state==\"gettingFloat\")\n"
."\tr[ix]=appendDigit(r[ix],n)\n"
."\telse {\n"
."\t\tr[ix] = \"\"+n\n"
."\t\tstate = \"gettingInteger\"\n"
."\t}\n"
."\tdisplay(r[ix])\n"
."}\n"
."function appendDigit(n1,n2) {\n"
."\tif(n1==\"0\") return \"\"+n2\n"
."\tvar s = \"\"\n"
."\ts+=n1\n"
."\ts+=n2\n"
."\treturn s\n"
."}\n"
."function display(s) {\n"
."\tdocument.calculator.total.value=s\n"
."}\n"
."function addDecimalPoint() {\n"
."\tif(state!=\"gettingFloat\") {\n"
."\t\tdecimal=true\n"
."\t\tr[ix]+=\".\"\n"
."\t\tif(state==\"haveOperand\" || state==\"getOperand2\") r[ix]=\"0.\"\n"
."\t\tstate=\"gettingFloat\"\n"
."\t\tdisplay(r[ix])\n"
."\t}\n"
."}\n"
."function clearDisplay() {\n"
."\tsetStartState()\n"
."\tdisplay(r[0])\n"
."}\n"
."function changeSign() {\n"
."\tif(r[ix].charAt(0)==\"-\") r[ix]=r[ix].substring(1,r[ix].length)\n"
."\telse if(parseFloat(r[ix])!=0) r[ix]=\"-\"+r[ix]\n"
."\tdisplay(r[ix])\n"
."}\n"
."function calc() {\n"
."\tif(state==\"gettingInteger\" || state==\"gettingFloat\" || state==\"haveOperand\") {\n"
."\t\tif(ix==1) {\n"
."\t\t\tr[0]=calculateOperation(operator,r[0],r[1])\n"
."\t\t\tix=0\n"
."\t\t}\n"
."\t}\n"
."\telse if(state==\"getOperand2\") {\n"
."\t\tr[0]=calculateOperation(operator,r[0],r[0])\n"
."\t\tix=0\n"
."\t}\n"
."\tstate=\"haveOperand\"\n"
."\tdecimal=false\n"
."\tdisplay(r[ix])\n"
."}\n"
."function calculateOperation(op,x,y) {\n"
."\tvar result=\"\"\n"
."\tif(op==\"+\") {\n"
."\t\tresult=\"\"+(parseFloat(x)+parseFloat(y))\n"
."\t}\n"
."\telse if(op==\"-\") {\n"
."\t\tresult=\"\"+(parseFloat(x)-parseFloat(y))\n"
."\t}\n"
."\telse if(op==\"*\") {\n"
."\t\tresult=\"\"+(parseFloat(x)*parseFloat(y))\n"
."\t}\n"
."\telse if(op==\"/\") {\n"
."\t\tif(parseFloat(y)==0) {\n"
."\t\t\talert(\"".("ERROR!")."\")\n"
."\t\t\tresult=0\n"
."\t\t}\n"
."\t\telse result=\"\"+(parseFloat(x)/parseFloat(y))\n"
."\t}\n"
."\treturn result\n"
."}\n"
."function performOp(op) {\n"
."\tif(state==\"start\") {\n"
."\t\t++ix\n"
."\t\toperator=op\n"
."\t}\n"
."\telse if(state==\"gettingInteger\" || state==\"gettingFloat\" || state==\"haveOperand\") {\n"
."\t\tif(ix==0) {\n"
."\t\t\t++ix\n"
."\t\t\toperator=op\n"
."\t\t}\n"
."\t\telse {\n"
."\t\t\tr[0]=calculateOperation(operator,r[0],r[1])\n"
."\t\t\tdisplay(r[0])\n"
."\t\t\toperator=op\n"
."\t\t}\n"
."\t}\n"
."\tstate=\"getOperand2\"\n"
."\tdecimal=false\n"
."}\n"
."// -->\n"
."</script>\n"
."<script language=\"JavaScript\">\n"
."<!--\n"
."setStartState()\n"
."// -->\n"
."</script>\n"
."<form name=\"calculator\">\n"
."<div align=\"center\"><center><table border=\"0\">\n"
."<TBODY><tr>\n"
."<td align=\"center\" colspan=\"3\"><input type=\"text\" size=\"20\" name=\"total\" value=\"0\"></td>\n"
."</tr><tr>\n"
."<td align=\"center\"><input type=\"button\" name=\"n1\" value=\" 1 \" onclick=\"addDigit(1)\" style=\"WIDTH: 35px\" width=\"35\"></td>\n"
."<td align=\"center\"><input type=\"button\" name=\"n2\" value=\" 2 \" onclick=\"addDigit(2)\" style=\"WIDTH: 35px\" width=\"35\"></td>\n"
."<td align=\"center\"><input type=\"button\" name=\"n3\" value=\" 3 \" onclick=\"addDigit(3)\" style=\"WIDTH: 35px\" width=\"35\"></td>\n"
."</tr><tr>\n"
."<td align=\"center\"><input type=\"button\" name=\"n4\" value=\" 4 \" onclick=\"addDigit(4)\" style=\"WIDTH: 35px\" width=\"35\"></td>\n"
."<td align=\"center\"><input type=\"button\" name=\"n5\" value=\" 5 \" onclick=\"addDigit(5)\" style=\"WIDTH: 35px\" width=\"35\"></td>\n"
."<td align=\"center\"><input type=\"button\" name=\"n6\" value=\" 6 \" onclick=\"addDigit(6)\" style=\"WIDTH: 35px\" width=\"35\"></td>\n"
."</tr><tr>\n"
."<td align=\"center\"><input type=\"button\" name=\"n7\" value=\" 7 \" onclick=\"addDigit(7)\" style=\"WIDTH: 35px\" width=\"35\"></td>\n"
."<td align=\"center\"><input type=\"button\" name=\"n8\" value=\" 8 \" onclick=\"addDigit(8)\" style=\"WIDTH: 35px\" width=\"35\"></td>\n"
."<td align=\"center\"><input type=\"button\" name=\"n9\" value=\" 9 \" onclick=\"addDigit(9)\" style=\"WIDTH: 35px\" width=\"35\"></td>\n"
."</tr><tr>\n"
."<td align=\"center\"><input type=\"button\" name=\"decimal\" value=\" . \" onclick=\"addDecimalPoint()\" style=\"WIDTH: 35px\" width=\"35\"></td>\n"
."<td align=\"center\"><input type=\"button\" name=\"n0\" value=\" 0 \" onclick=\"addDigit(0)\" style=\"WIDTH: 35px\" width=\"35\"></td>\n"
."<td align=\"center\"><input type=\"button\" name=\"plus\" value=\" + \" onclick=\"performOp('+')\" style=\"WIDTH: 35px\" width=\"35\"></td>\n"
."</tr><tr>\n"
."<td align=\"center\"><input type=\"button\" name=\"minus\" value=\" - \" onclick=\"performOp('-')\" style=\"WIDTH: 35px\" width=\"35\"></td>\n"
."<td align=\"center\"><input type=\"button\" name=\"multiply\" value=\" x \" onclick=\"performOp('*')\" style=\"WIDTH: 35px\" width=\"35\"></td>\n"
."<td align=\"center\"><input type=\"button\" name=\"divide\" value=\" / \" onclick=\"performOp('/')\" style=\"WIDTH: 35px\" width=\"35\"></td>\n"
."</tr><tr>\n"
."<td align=\"center\"><input type=\"button\" name=\"equals\" value=\" = \" onclick=\"calc()\" style=\"WIDTH: 35px\" width=\"35\"></td>\n"
."<td align=\"center\"><input type=\"button\" name=\"sign\" value=\" +/- \" onclick=\"changeSign()\" style=\"WIDTH: 35px\" width=\"35\"></td>\n"
."<td align=\"center\"><input type=\"button\" name=\"clearField\" value=\" C \" onclick=\"clearDisplay()\" style=\"WIDTH: 35px\" width=\"35\"></td>\n"
."</tr></TBODY></table>\n"
."</center></div></td></tr></table></form></td></tr></table>\n";
?>
|
|
|
| Back to top |
|
 |
bobby Site Admin


Joined: Jan 20, 2009 Posts: 779 Location: North Carolina
|
|
| Back to top |
|
 |
bestbuildpc I might as well work here


Joined: Nov 16, 2009 Posts: 100
|
|
| Back to top |
|
 |
bobby Site Admin


Joined: Jan 20, 2009 Posts: 779 Location: North Carolina
|
Posted: Mon Jul 09, 2012 5:20 pm Post subject: |
|
|
| |
|
| Back to top |
|
 |
bestbuildpc I might as well work here


Joined: Nov 16, 2009 Posts: 100
|
|
| Back to top |
|
 |
montego Regular


Joined: Dec 04, 2010 Posts: 19
|
Posted: Tue Jul 10, 2012 8:19 am Post subject: |
|
|
| bestbuildpc wrote: | | Any book or site to learn? I wonder if it is possible to create a a program to validate a file .php which contains html. I don't know if that exist. |
My advice on the subject:
When building your site, start with the latest RavenNuke(tm) version that is 100% valid (unless you knowly turn on the scrolling Downloads block - yes, I know -  ). Then, when you add non-core RN team provided modules, blocks, hacks, start with only one at a time and fix that particular module, block, hack validation errors until the site is clean again. For example, in your case below, first make sure your site validates, then add that one block. Now you know that any validation errors are going to be strictly from that block. So, work on cleaning up the PHP code that is generating the HTML, one issue at a time.
This all works so much better, too, when you host a copy of your site locally on your PC using some type of WAMP or LAMP server set up (such as XAMPP - my favorite on Windows). For me, it is a mirror image of my production site. I make changes first locally, thoroughly test both functionality and compliance (using the already mentioned FireFox plug-in) prior to installing up to my production site.
There is no validator that will work on PHP code. There is just too much variation in code, IMO, to really accomplish this. So, the above is your only option. |
|
| Back to top |
|
 |
bobby Site Admin


Joined: Jan 20, 2009 Posts: 779 Location: North Carolina
|
Posted: Tue Jul 10, 2012 8:59 am Post subject: |
|
|
| bestbuildpc wrote: | A million of thanks. I am gonna check those links.
Edit: Bobby, I understand almost all but my problem is when this xhtml file is converted to php then I can not understand where to put the / o r /> at the end to close it. |
XHTML is the same regardless of the parent language it is in. All open tags have to be closed and the must be closed in the proper order. By this, I mean that you can't just close a tag where you want to.
Example:
<div><span><u>code... </u></span></div>
can not be
<div><span><u>code...</span></u></div>
because the span was opened before the underline tag so the underline tag has to be closed before the span tag is.
Some things like <br /> or <hr /> are self closing tags. They do not enclose code within them.
No one can teach you proper coding, you need to use the millions of free resources available on the internet. If you really want to understand how it works, start with the basics and go from there. Start with a basic single page html and css stylesheet site and go from there. Once you understand that, move to html within php or asp or whatever language you want to learn. _________________ Tricked Out News |
|
| Back to top |
|
 |
bobby Site Admin


Joined: Jan 20, 2009 Posts: 779 Location: North Carolina
|
Posted: Tue Jul 10, 2012 11:53 am Post subject: |
|
|
I am going to give you a simple example of using html with css classes to design a webpage.
The first thing to remember is that there are prefered methods to do this and alternate methods. It is best to stick to the prefered methods as much as possible. I will explain why you have to use different methods later on.
The prefered method is to place all of your styling in a css file assigning class elements to the html tags.
http://www.w3.org/TR/2003/WD-xhtml2-20030506/mod-styleSheet.html
Once you have included the style sheet in your html head, you will move to the actual body of the document.
In your css file, add some styling to the body of the site like so:
Code:body {
margin: 0; padding: 0;
font: 70%/1.5 Verdana, Tahoma, Arial, Helvetica, sans-serif;
color: #333;
background-color: #efefef;
}
|
Now everything inside the opening and closing body tags will have these properties.
Lets start with a pair of divs as the wrapper of the page.
Code:<body><div class="mainwrapper">
</div></body>
|
Notice that I have already closed the opening div. I did this because the content of the page will be within this main div. Now we need to add some styling to this div. In our css file, we will add something like this:
http://www.w3schools.com/css/css_examples.asp
Code:
body {
margin: 0; padding: 0;
font: 70%/1.5 Verdana, Tahoma, Arial, Helvetica, sans-serif;
color: #333;
background-color: #efefef;
.mainwrapper{
margin: 0 auto;
width: 980px;
background-color:#b0c4de;
}
|
Now we have a styled body with a centered div that is 980px wide with a background color of #b0c4de.
Inside there you would add your header:
Code:<body><div class="mainwrapper">
<div class="header"></div>
</div></body>
|
And the styling would look like this:
Code:body {
margin: 0; padding: 0;
font: 70%/1.5 Verdana, Tahoma, Arial, Helvetica, sans-serif;
color: #333;
background-color: #efefef;
.mainwrapper {
margin: 0 auto;
width: 980px;
background-color:#b0c4de;
}
.header {
background-image:url('image.gif');
width: 980px;
height: 320px;
}
|
You would then float divs to hold you content below. These are just examples with incomplete styling. You would need to deal with padding and margins as well as positioning. You can use spans inside your positioning divs to style content. _________________ Tricked Out News |
|
| Back to top |
|
 |
bestbuildpc I might as well work here


Joined: Nov 16, 2009 Posts: 100
|
Posted: Tue Jul 10, 2012 2:17 pm Post subject: |
|
|
| Quote: | <div><span><u>code... </u></span></div>
can not be
<div><span><u>code...</span></u></div>
because the span was opened before the underline tag so the underline tag has to be closed before the span tag is.
Some things like <br /> or <hr /> are self closing tags. They do not enclose code within them. |
Bobby, this is what I didn't understand. Now I got it. It is Incredible how this validation works.
I also thought this example was ok but actually not
Not good
Code:<input>content...</input>
|
Good
Code:<input content="test" />
|
|
|
| Back to top |
|
 |
|
|