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

  • Home
  • SEARCH
  • 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 9018943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:39:31+00:00 2026-06-16T04:39:31+00:00

Possible Duplicate: changing the img src with jquery The title may make this sound

  • 0

Possible Duplicate:
changing the img src with jquery

The title may make this sound easy, and it probably is. but i, with my incredibly small knowledge of js, am finding it incredibly nerve wracking… basically i have pictures set in a form (lets say img1 img2 and img3) and i want the user to be able to click on an image and it will change to a different one, for instance you click on img1 and it becomes img1a. and etc, heres the code:

<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" /></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>

there are currently checkboxes, however those will be hidden, so i need the images to change on click to show the user that it is in fact selected, any ideas guys?

  • 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-16T04:39:32+00:00Added an answer on June 16, 2026 at 4:39 am

    In the image tag add an onclick event and add the javascript there to change the image source.

    <script type="text/javascript">
    function func()
    {
        var img1= document.getElementById("img1");
    
        if(img1.name == "on")
        {
            img1.src = "/images/" + "img1a.jpg";
            img1.name = "off";
        }
        else
        {
            img1.src = "/images/" + "img1.jpg";
            img1.name = "on";
        }
    }
    </script>
    
    <img src="/images/img1.jpg" width="781" height="800" onclick="func()" id="img1" name="on" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate JavaScript: Changing src-attribute of a embed-tag but this is not working for
Possible Duplicate: changing the output This is the code: def voting_borda(args): results = {}
Possible Duplicate: Changing Icon per Day How to make a dynamic icon? For example
Possible Duplicate: Changing only y pos of background image via Jquery I want to
Possible Duplicate: changing password field to text with checkbox with jquery The code is
Possible Duplicate: How do I make a request using HTTP basic authentication with PHP
Possible Duplicate: How can I understand nested ?: operators in PHP? Why does this:
Possible Duplicate: Can main function call itself in C++? I found this problem very
Possible Duplicate: Django data migration when changing a field to ManyToMany how I can
Possible Duplicate: php edit for Cufon font replacement I am reposting this due to

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.