Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9099031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T00:30:39+00:00 2026-06-17T00:30:39+00:00

I can not seem to get checkbox.checked to work, I have a script that

  • 0

I can not seem to get checkbox.checked to work, I have a script that changes an image based onclick() however i would like it to change it based on whether a checkbox is checked or not. what am i doing wrong? Also if someone may be able to adress this, the check boxes do not check in ie8

here is the live link: http://jsbin.com/uburan/1/edit

code:

<script type="text/javascript">
function func()
{
    var img1= document.getElementById("img1");

    if(checkbox.checked)
    {
        img1.src = "images/" + "img1a.jpg";
        img1.name = "off";
    }
    else
    {
        img1.src = "images/" + "img1.jpg";
        img1.name = "on";
    }
}
</script>



</head>

<body>
<form>
<p align="center">
<input type="checkbox" name="interest1" id="interest1" value="x">
<input type="checkbox" name="interest2" id="interest2" value="x">
<input type="checkbox" name="interest3" id="interest3" value="x"></p>   
<p align="center">
<label for="interest1" id="label-interest1"><img src="images/img1.jpg" width="781" height="800" onclick="func()" id="img1" /></label>
<label for="interest2" id="label-interest2"><img src="/images/img2.jpg" width="781" height="800" /></label>
<label for="interest3" id="label-interest3"><img src="/images/img3.jpg" width="781" height="800" /></label></P><!-- code making checkbox be an image-->
</form>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T00:30:41+00:00Added an answer on June 17, 2026 at 12:30 am

    You have to specify the ID of the checkbox (or its reference inside the DOM). Something like this:

    if(document.getElementById('interest1').checked)
    {
        // blah
    }
    

    If you want to check if they’re all checked:

    if(document.getElementById('interest1').checked && 
       document.getElementById('interest2').checked &&
       document.getElementById('interest3').checked) {
    
        // blah
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Am I not seeing something obvious here, can't seem to get this to work...
I have made a cool looking scrollbar. I can not seem to get this
I can't seem to get this to work. If I remove the checkbox portion
I have a Resident and can not seem to get the set of SSA's
I have tried several different submit buttons but can not seem to get this
I can not seem to get the date to insert from my form into
I seem to cannot get this to work. So I have a bunch of
I can not seem to get comments per movie from moviesDetail.jsp. What am I
I tried using manova() and can not seem to get the correct programming in.
Can't seem to get checkbox to be validate on client-side using asp.net mvc 2.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.