eequalsmc2plus1
Programmer
Hey,
Anyone know a way that I can have a table and when a cell in the table is clicked a picture is loaded into the cell.
I wrote this code, but the cells dont have pictures in them before they are clicked and my code puts those boxes with little x's in the cells. I need them to be completely empty, actually got a picture on the background of the table so the x's screw it up. Was thinking of putting a clear gif file as the picture of each cell before they are clicked, but that cant be the best was.
Please help ... thanks, heres the code I wrote so far.
<HTML>
<HEAD>
</HEAD>
<BODY>
<TABLE>
<tr>
<td width=52 height=48>
<A href="javascript:yourChoice('A')"><IMG name="A" height=48 src="" width=52 border=0></A>
</td>
<td width=52 height=48>
</td>
<td width=52 height=48>
</td>
<td width=52 height=48>
<A href="javascript:yourChoice('B')"><IMG name="B" height=48 src="" width=52 border=0></A>
</td>
<td width=52 height=48>
</td>
<td width=52 height=48>
</td>
<td width=52 height=48>
<A href="javascript:yourChoice('C')"><IMG name="C" height=48 src="" width=52 border=0></A>
</td>
</tr>
</TABLE>
</BODY>
</HTML>
<SCRIPT language=JavaScript>
var temp = "";
var ok = 0;
var A = "";
var B = "";
var C = "";
var current = 1;
function yourChoice(chName) {
temp = chName;
checkspace();
if (ok == 1){
document.images[chName].src = "pics/2.jpg";
} else {
alert("Theres a piece there already fool."
}
}
function checkspace(){
ok = 0;
if ((temp == "A"&&(A == "") {
ok = 1;
A = current;
}
if ((temp == "B"&&(B == "") {
ok = 1;
B = current;
}
if ((temp == "C"&&(C == "") {
ok = 1;
C = current;
}
}
</SCRIPT>
Anyone know a way that I can have a table and when a cell in the table is clicked a picture is loaded into the cell.
I wrote this code, but the cells dont have pictures in them before they are clicked and my code puts those boxes with little x's in the cells. I need them to be completely empty, actually got a picture on the background of the table so the x's screw it up. Was thinking of putting a clear gif file as the picture of each cell before they are clicked, but that cant be the best was.
Please help ... thanks, heres the code I wrote so far.
<HTML>
<HEAD>
</HEAD>
<BODY>
<TABLE>
<tr>
<td width=52 height=48>
<A href="javascript:yourChoice('A')"><IMG name="A" height=48 src="" width=52 border=0></A>
</td>
<td width=52 height=48>
</td>
<td width=52 height=48>
</td>
<td width=52 height=48>
<A href="javascript:yourChoice('B')"><IMG name="B" height=48 src="" width=52 border=0></A>
</td>
<td width=52 height=48>
</td>
<td width=52 height=48>
</td>
<td width=52 height=48>
<A href="javascript:yourChoice('C')"><IMG name="C" height=48 src="" width=52 border=0></A>
</td>
</tr>
</TABLE>
</BODY>
</HTML>
<SCRIPT language=JavaScript>
var temp = "";
var ok = 0;
var A = "";
var B = "";
var C = "";
var current = 1;
function yourChoice(chName) {
temp = chName;
checkspace();
if (ok == 1){
document.images[chName].src = "pics/2.jpg";
} else {
alert("Theres a piece there already fool."
}
}
function checkspace(){
ok = 0;
if ((temp == "A"&&(A == "") {
ok = 1;
A = current;
}
if ((temp == "B"&&(B == "") {
ok = 1;
B = current;
}
if ((temp == "C"&&(C == "") {
ok = 1;
C = current;
}
}
</SCRIPT>