• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Fetching one table cell click and passing it to servlet

 
Navya J Nair
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Please help !!!

I am building a TicTacToe game web-services application using jsp and servlet where I need to extract the table's cell onclick event each time for each user and pass is to servlet.

The code so far I have built is :

</script>
<style type="text/css">
body{
text-align: center;
}
table{
text-align: center;
table-layout:fixed;
}
</style>
</head>

<body>
<form action="TicTacToeGame" method="post">

<table id="board" border=1 align=left cellpadding="2" cellspacing="3" width="250" height="250" >
<tr>
<td> <input type="button" name="11" /> </td>
<td> <input type="button" name="12" /> </td>
<td> <input type="button" name="13" /> </td>
</tr>
<tr>
<td> <input type="button" name="21" /> </td>
<td> <input type="button" name="22" /> </td>
<td> <input type="button" name="23" /> </td>
</tr>
<tr>
<td> <input type="button" name="31" /> </td>
<td> <input type="button" name="32" /> </td>
<td> <input type="button" name="33" /> </td>
</table>
<div>
<input type="submit" name="submit" value="MyMove">
</div>

</form>
</body>

</html>
 
Paul Clapham
Sheriff
Posts: 20986
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Navya J Nair wrote:I need to extract the table's cell onclick event each time for each user and pass is to servlet.


In other words, you need to do something with Javascript but you don't know exactly what. That doesn't make it a question about Servlets, it makes it a question about Javascript. Which we have a forum for, so let's move the post over there.
 
Navya J Nair
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry about that.Yes I need to fetch using javascript of table cell's click at a single time for one player.Please help.I am stuck up with this.
 
Navya J Nair
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am building a TicTacToe game web-services application using jsp and servlet where I need to extract the table's cell onclick event each time for each user and pass is to servlet using javascript

The code so far I have built is :


 
Paul Clapham
Sheriff
Posts: 20986
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And so those <input> elements are what you're calling "table cells"? Is your question how to add "onclick" attributes to those elements, or what?
 
Navya J Nair
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for all the replies.
Actually I have a ques regarding the table cell.Can we make use of only table <td> and have onclick event on that. or should have to use any input type like button.
And at a time we need to make use of 1 click on 1 button .So how can we make fetch the cell events in javascript
 
Paul Clapham
Sheriff
Posts: 20986
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If your question was "Does the <td> tag support the onclick attribute?" then let me just point out that any basic HTML resource should tell you that. I would strongly recommend that you find one: you'll find it much easier if you just look it up rather than waiting for hours just to find one simple answer.
 
Navya J Nair
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am looking but its quite complicated as we need to find only one onclick event at a time of 1 player.
 
Paul Clapham
Sheriff
Posts: 20986
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't see why that makes it complicated. When the user clicks on something which has an onclick attribute, you get an onclick event. The user can only click on one thing at a time, so you can only get one onclick event at a time.
 
Navya J Nair
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

This is Tictactoe game-
my concern is when user clicks/make move on button it should write a content and it needs to be saved in database and then it has to again fetched back from db when 2nd player is ready for placing his mark/move on other button it

hope you got it
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic