if then checkbox.checked move image
hello
i have 40 checkboxes with corresponding images scaled down on a page. the user can only click up to 3 checkboxes. If they click a 4th an alert tells user to unclick one before clicking this one.
at the bottom of the page are 3 images full size for their image choices. when user clicks any checkbox i would like the corresponding image to show instead of one of the 3 images that are there.
i have looked online for an answer but most of them are in relation to 1 image or 1 checkbox. i have tried several scripts but none seem to move the image to elsewhere. they are all show/hide.
i could do something like hide all the images in each of the choice boxes & upon checking the box the right image would show but im not sure how to do it for 3 boxes & not have them repeat.
if user clicks on check5, check 9 & check25 the choice boxes below would show image 5, image 9 & image 25. if user changes choice from image 9 to image 11 will image 11 show in the right choice box?
all images & checkboxes are named accordingly.
check1 & hhcard1
check2 & hhcard2
check3 & hhcard3 & so on.
i have only posted the code for 4 checkboxs/images
HTML Code:
<div id="cards" align="center" style="width: 95%">
<table align="center" border="0" cellpadding="0" cellspacing="0" width="90%" height="650">
<tr>
<td width="11%" align="center" height="21"><b><i><font face="Lucida Console" size="2">CARD
1 <input type="checkbox" name="whatcard" value="Card 1" id=check1 onclick="return toggle(this);" >
</font></i></b></td>
<td width="11%" align="center" height="21"></td>
<td width="11%" align="center" height="21"><font face="Lucida Console" size="2"><i><b>CARD
2 <input type="checkbox" name="whatcard" value="Card 2" id=check2 onclick="return toggle(this);">
</b></i></font></td>
<td width="11%" align="center" height="21"></td>
<td width="11%" align="center" height="21"><b><i><font face="Lucida Console" size="2">CARD
3 <input type="checkbox" name="whatcard" value="Card 3" id=check3 onclick="return toggle(this);">
</font></i></b></td>
<td width="11%" align="center" height="21"></td>
<td width="11%" align="center" height="21"><b><i><font face="Lucida Console" size="2">CARD
4 <input type="checkbox" name="whatcard" value="Card 4" id=check4 onclick= "return toggle(this);">
</font></i></b></td>
</tr>
<tr>
<td width="11%" height="21">
<img border="0" src="images/cards/hhcard1.gif" width="172" height="222" id=hhcard1 ></td>
<td width="11%" height="21"></td>
<td width="11%" height="21">
<img border="0" src="images/cards/hhcard2.gif" id=pic2 width="172" height="222" id=hhcard2></td>
<td width="11%" height="21"></td>
<td width="11%" height="21">
<img border="0" src="images/cards/hhcard3.gif" id=pic3 width="172" height="222" id=hhcard3></td>
<td width="11%" height="21"></td>
<td width="11%" height="21">
<img border="0" src="images/cards/hhcard4.gif" id=pic4 width="172" height="222" id=hhcard4></td>
</tr>
<hr>
<div id="choices" align="center" style="width: 98%">
<table align="center" class="auto-style2" style="width: 100%; text-align: center;">
<tr>
<td id="choice1"><img border="0" src="images/cards/templateblank.gif" width="287" height="366" ></td>
<td id="choice2"><img border="0" src="images/cards/templateblank.gif" width="287" height="366" ></td>
<td id="choice3"><img border="0" src="images/cards/templateblank.gif" width="287" height="366" ></td>
</tr>
</table>
</div>
and the java is as follows:
Code:
<script type="text/javascript">
var checked=0;
function toggle(box) {
if( (box.checked == true) && (checked < 3) ) {
checked++;
return true;
}
else if( (box.checked == true) && (checked == 3) ) {
alert("OOPS! You already picked 3 BINGO cards!\n \nYou must uncheck another card before you can check this one.\n");
return false;
} else {
checked--;
return true;
}
}
</script>
is there a way to make the current function do what i need since its already set up on each checkbox?
thanks for any help in advance. i been trying everything for the past couple weeks & im beyond frustrated.
HippieChickie