warewolfe Posted March 8, 2007 Share Posted March 8, 2007 Hi, I'm new to javascript and trying to get this thing up and running as a glorified hello world script. The testfunction works as expected but I can't seem to get the innerHTML of the table. Anybody know whats up? <?php /* * This functions just provides a simple id name for * each cell. It could probably have been done easier */ function getCellID($ii,$jj) { $answer= 'c'.$ii.$jj; return $answer; } /* * This function gives the table a cross hatch look */ function sortTDType($ii,$jj) { $answer="tdp"; if($jj>=3 && $jj<=5) { $answer="tdh"; } else if($ii >= 3 && $ii <=5) { $answer="tdh"; } if(($ii >= 3 && $ii<=5)&& ($jj >= 3 && $jj <= 5)) { $answer="tdp"; } return $answer; } ?> <html> <head> <title>Sodoku Solver Prototype seven</title> <link rel="stylesheet" type="text/css" href="prototype7.css" /> <script language = "JavaScript" type="text/javascript"> <!-- function validCheck(var1,var2) { var answer=true; var vector='c'+var1+var2; var vectorValue =document.getElementById(vector).value; //column check for(var ii=0;ii<=8;ii++) { var checkCount=ii+1; var testVector='c'+ii+var2; var testVectorValue = document.getElementById(testVector).value; /* alert('check ' + checkCount + ' : vector '+ vector+ '= ' + vectorValue + ' : testVector ' +testVector +'= ' + testVectorValue); */ if(vectorValue==testVectorValue && vector != testVector && vectorValue!=0) { alert('You Can not put that there, clash on column!'); answer=false; break; } }//end for loop //row check for(var ii=0;ii<=8;ii++) { var checkCount=ii+1; var testVector='c'+var1+ii; var testVectorValue = document.getElementById(testVector).value; /* alert('check ' + checkCount + ' : vector '+ vector+ '= ' + vectorValue + ' : testVector ' +testVector +'= ' + testVectorValue); */ if(vectorValue==testVectorValue && vector != testVector && vectorValue!=0) { alert('You can not put that there, clash on the row'); answer=false; break; } }//end for loop return answer; }//end function validCheck function resetField(var1,var2) { var vid='c'+var1+var2; document.getElementById(vid).innerHTML ='0'; } function validEntry(var1,var2) { var vector='c'+var1+var2; var orginal= document.getElementById(vector).value; if(!validCheck(var1,var2)) { alert('Not working, try again'); resetField(var1,var2); } } //--> </script> </head> <body> <h1>Prototype 7:Intial Form Side</h1> <h2>Input the initial sodoku form</h2> <form action="Prototype7Script.php" method="post"> <table class="displayTable"> <?php for($ii=0;$ii<=8;$ii++) { echo"<tr>"; for($jj=0;$jj<=8;$jj++) { $cellID=getCellID($ii,$jj); $tdtype=sortTDType($ii,$jj); echo"<td> <input class=\"$tdtype\" type=\"text\" value=\"0\" size=\"1\" maxlength=\"1\" id=\"$cellID\" name=\"data[$ii][]\" onblur=\"validEntry($ii,$jj)\" /> </td>"; } echo"</tr>"; } ?> </table> <input type="submit" value="submit"> </form> <script type="text/javascript"> function testText() { document.getElementById('testID').innerHTML = 'zzzz'; } </script> <p>Another <b id='testID'>test</b></p> <input type='button' onclick='testText()' value='tester button' /> </body> </html> Quote Link to comment Share on other sites More sharing options...
fenway Posted March 8, 2007 Share Posted March 8, 2007 I'm not sure I understand what you mean... but tables don't really have an "inside" per se. Quote Link to comment Share on other sites More sharing options...
warewolfe Posted March 8, 2007 Author Share Posted March 8, 2007 Just had a D'oh moment. To clarify for any interested, For some reason, I don't understand just yet, if I want to change the something the page displays outside of a table I use; document.getElementById.innerHTML = "some value"; but inside of a table <td> tag I need to use; document.getElementById.value="some value"; Quote Link to comment Share on other sites More sharing options...
fenway Posted March 8, 2007 Share Posted March 8, 2007 TD's don't have values.... only INPUTs do. Quote Link to comment 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.