Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-09-2012, 05:17 PM   PM User | #1
goldie
New to the CF scene

 
Join Date: Nov 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
goldie is an unknown quantity at this point
checkbox to call images

My knowledge of JavaScript is very limited but hopefully not for long. HTML and CSS I do have some know how.
I have created a form; specifically a checkbox and when the checkbox is ticked I have an image that is displayed. My question is this – Is it possible to have more than one image display when one checkbox has been clicked? I would like to have 10-20 images display when one checkbox has been ticked. Any direction on this would be much appreciated.
TIA
goldie is offline   Reply With Quote
Old 11-09-2012, 05:34 PM   PM User | #2
xelawho
Senior Coder

 
xelawho's Avatar
 
Join Date: Nov 2010
Posts: 2,437
Thanks: 52
Thanked 454 Times in 452 Posts
xelawho will become famous soon enoughxelawho will become famous soon enough
are they always the same images? if so, just put them all into a hidden div and show/hide it depending on what happens with the checkbox

Code:
<html>
<head>
<style>
#picsdiv{
display:none;
}
</style>
</head>
<body>
<input type="checkbox" id="mycb" onclick="showHide(this)"/>
<div id="picsdiv">put your images here</div>
<script type="text/javascript">
function showHide(box){
document.getElementById("picsdiv").style.display=box.checked?"block":"none";
}
</script>
</body>
</html>
xelawho is offline   Reply With Quote
Old 11-09-2012, 06:41 PM   PM User | #3
goldie
New to the CF scene

 
Join Date: Nov 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
goldie is an unknown quantity at this point
Quote:
Originally Posted by xelawho View Post
are they always the same images? if so, just put them all into a hidden div and show/hide it depending on what happens with the checkbox

Code:
<html>
<head>
<style>
#picsdiv{
display:none;
}
</style>
</head>
<body>
<input type="checkbox" id="mycb" onclick="showHide(this)"/>
<div id="picsdiv">put your images here</div>
<script type="text/javascript">
function showHide(box){
document.getElementById("picsdiv").style.display=box.checked?"block":"none";
}
</script>
</body>
</html>
Yes they would all be the same image but eventually I would like to add a rollover or onclick event to each image. Would this still work?

ex: I would like one checkbox that when ticked would display 10 images which would all be the same image but when a user rollsover or clicks each image a text box would display with addtional info, which would be different for each image.

Hope I am explaining this clearly
goldie is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:15 AM.


Advertisement
Log in to turn off these ads.