troubleshooting Question

Techniques for displaying game board

Avatar of Tom Knowlton
Tom KnowltonFlag for United States of America asked on
5 Comments1 Solution316 ViewsLast Modified:
Right now I am using an ASP page to create a 10 row  X  10 column table.

Then I am filling that table with images (as I read through a dataset from an Access Table):

My question I need a HTML table structure to do all of this?

Here is the full ASP source (below).  The only reason I am "doing it this way" is because I am a complete novice at this....and I don't know any better.

If there is a better way to do what I am trying to do, then please give me some pointers.  :)




<!--#include File="connections.asp" -->

Dim sInitGame
'Dim moveState
'squareOne = "One"
'squareTwo = "Two"
sInitGame = Request.Form("newgame")
'sInitGame = "New Game"

if request("subform") = "Yes" then
      Response.Write "Subform value was YES"
       strUp = "UPDATE tblGameBoard, tblGameBoard tb SET tblGameBoard.[Image] = tb.[Image] WHERE tblGameBoard.SquareID="&request("NewSqID")&" AND tb.SquareID = "&request("OldSqID")&";"
      strUp2 = "Update tblGameBoard set [Image]='blank' Where SquareID = "&request("OldSqID")
end if

<form name="GameForm" action="game.asp" method=get>

call sbInitGame()

Sub sbInitGame()
      response.Write "Initializing Game"
      response.Write "<br><br><br>"
      response.Write "Game board:   Click a game piece to select it, then click new square to move game piece to"
      response.Write "<br><br><br>"
       set rs=Server.CreateObject("ADODB.recordset")
      rs.CursorType = 3
      sql="select [Row], [Column], [Image], [Value], [SquareID] from tblGameBoard where GameNumber='1' Order by [Row], [Column]"
        rs.Open sql, Conn
      if (rs.EOF or rs.BOF) then                
          response.write "No Row in the table<br>"
            do until rs.eof    
                  currentRow = rs("row")
                  currentImage = rs("Image")
                  ValueReadIn = rs("Value")
                if not(currentRow = oldRow) then
                end if%>
                  <td onclick="OnSquareClick('<%=rs("SquareID")%>','<%=currentImage%>','<%=ValueReadIn%>')">
              <img src="images\<%=currentImage%>.jpg">
                 <%oldRow = currentRow
                 rs.MoveNext     'This tells the rows to move to the next row
            loop          'This tells the 'DO UNTIL' to move on and do it all over again.
          set rs=nothing     'Its a really good idea to close recordsets and connections when your done.
      end if                
End Sub

<!--#include File="closeconnections.asp" -->

Old Square ID:&nbsp;&nbsp;<input name="OldSqID" value="None">
New Square ID:&nbsp;&nbsp;<input name="NewSqID" value="None">
Item Value First:&nbsp;&nbsp;<input name="ItemValueFirst" value="None">
Item Value Second:&nbsp;&nbsp;<input name="ItemValueSecond" value="None">
Sub Form:&nbsp;&nbsp;<input name="SubForm" value="No">


<script type="text/javascript"  language="Javascript">

function OnSquareClick(square,imagename,ValueOfItem)
  if(Origin.value == Dest.value)
    Origin.value = square;
      VOI_First.value= ValueOfItem;
    SubForm.value = "No";
  else if(Origin.value != Dest.value)
    Dest.value = square
    SubForm.value = "Yes";
}//End of OnSquareClick

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros