/    Sign up×
Community /Pin to ProfileBookmark

How to add sign positive to checkbox?

I would like to add image positive if user clicks on checkbox within my form but there are many checkboxes with options and many questions.

How to do with javascript?

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@triassicAug 19.2009 — Just put the images there to begin with, but set their css visibility to hidden, and all with unique IDs. Then when a checkbox is clicked set document.getElementById('<id>').style.visibility=visible.
Copy linkTweet thisAlerts:
@toplisekauthorAug 20.2009 — Can you send me example please?
Copy linkTweet thisAlerts:
@triassicAug 20.2009 — [CODE]<img src="pic.gif" id="test" style="visibility:hidden;" />
<a href="#" onclick="document.getElementById('test').style.visibility='visible';">Do It</a>[/CODE]
Copy linkTweet thisAlerts:
@JMRKERAug 20.2009 — I thought the question related to checkboxes ?, so I made this version:
<i>
</i>&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Checkbox Indicator&lt;/title&gt;

&lt;script type="text/javascript"&gt;
// For: http://www.webdeveloper.com/forum/showthread.php?t=215185

function CBoxPlus(elem) {
var sel = document.getElementById(elem.id);
var sel_bg = document.getElementById(elem.id+'_bg');
if (sel.checked) { sel_bg.style.visibility = 'visible'; }
else { sel_bg.style.visibility = 'hidden'; }
}
&lt;/script&gt;

&lt;/head&gt;
&lt;body&gt;

&lt;span id="cb1_bg" style="visibility:hidden"&gt;
&lt;img src='http://www.hscripts.com/freeimages/icons/symbols/math/plus/plus5.gif'&gt;
&lt;/span&gt;
&lt;input type="checkbox" id="cb1" onclick="CBoxPlus(this)"&gt;Check Me!&lt;br&gt;

&lt;span id="cb2_bg" style="visibility:hidden"&gt;
&lt;img src='http://www.hscripts.com/freeimages/icons/symbols/math/plus/plus5.gif'&gt;
&lt;/span&gt;
&lt;input type="checkbox" id="cb2" onclick="CBoxPlus(this)"&gt;Check Me!&lt;br&gt;

&lt;span id="cb3_bg" style="visibility:hidden"&gt;
&lt;img src='http://www.hscripts.com/freeimages/icons/symbols/math/plus/plus5.gif'&gt;
&lt;/span&gt;
&lt;input type="checkbox" id="cb3" onclick="CBoxPlus(this)"&gt;Check Me!&lt;br&gt;

&lt;span id="cb4_bg" style="visibility:hidden"&gt;
&lt;img src='http://www.hscripts.com/freeimages/icons/symbols/math/plus/plus5.gif'&gt;
&lt;/span&gt;
&lt;input type="checkbox" id="cb4" onclick="CBoxPlus(this)"&gt;Check Me!&lt;br&gt;

&lt;span id="cb5_bg" style="visibility:hidden"&gt;
&lt;img src='http://www.hscripts.com/freeimages/icons/symbols/math/plus/plus5.gif'&gt;
&lt;/span&gt;
&lt;input type="checkbox" id="cb5" onclick="CBoxPlus(this)"&gt;Check Me!&lt;br&gt;

&lt;/body&gt;
&lt;/html&gt;

Good Luck!

?
Copy linkTweet thisAlerts:
@toplisekauthorAug 21.2009 — Hi your versio is fine but issue is that needs replacement of [B]checkbox[/B] with an arrow not beside checkbox. Is this possible?
Copy linkTweet thisAlerts:
@JMRKERAug 21.2009 — I would like to add image positive if user clicks on checkbox within my form but there are many checkboxes with options and many questions.

How to do with javascript?[/QUOTE]


Hi your versio is fine but issue is that needs replacement of checkbox with an arrow not beside checkbox. Is this possible?[/QUOTE]

Please clarify.


You asked to "add image positive if user clicks on a checkbox" in original post.

We did that.

Now you want to replace the checkbox? ... or you want to replace the '+' image?

Use a different '.gif/.jpg' image if the latter.

Explain further or show example if the former ...
×

Success!

Help @toplisek spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...