|
-
Oct 26th, 2005, 07:22 AM
#1
Thread Starter
Lively Member
"Click event"
I'm working on a chessgame right now. I have a table with black and white fields.... Over those fields there are images with transparent backgrounds.
Now the problem.
I want the backgroundcolor to change if someone clicks on the field. Is there a way to do that without reloading the page because i want the user to click at the 2nd field right after that?!
Please help
FES
-
Oct 26th, 2005, 10:37 AM
#2
Thread Starter
Lively Member
Re: "Click event"
In other words. I need to know how.
-To change the backgroundcolor of the table without reloading the form
-How to make a "click event" for a table.
PLEASE HELP!
FES
-
Oct 26th, 2005, 12:36 PM
#3
-
Oct 26th, 2005, 01:30 PM
#4
Lively Member
Re: "Click event"
You could change the background color when they click the cell:
Code:
<html>
<head>
<script type="text/javascript">
function ChangeColor(elm, color1, color2)
{
if(elm.style.background.indexOf(color2) != -1)
{
elm.style.background = color1;
}
else
{
elm.style.background = color2;
}
}
</script>
</head>
<body>
<table>
<tr>
<td style="background-color: white;" width="200" height="200" onclick="ChangeColor(this, 'black', 'white');">
cell
</td>
</tr>
<tr>
<td style="background-color: white;" width="200" height="200" onclick="ChangeColor(this, 'black', 'white');">
cell
</td>
</tr>
</table>
</body>
</html>
-
Oct 26th, 2005, 01:34 PM
#5
Thread Starter
Lively Member
Re: "Click event"
k. that should work
thanks
-
Oct 26th, 2005, 03:35 PM
#6
Thread Starter
Lively Member
Re: "Click event"
houston we got a problem:
1. How do i change the value of a variable (php)
2. Is it really necessary to use php AND javascript?? Is there no way to do it in vb??
That's why i originally posted it in php.
Plz help again.
FES
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|