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 7796669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:26:21+00:00 2026-06-01T23:26:21+00:00

I would like to make a checkbox form that has both mouse over image

  • 0

I would like to make a checkbox form that has both mouse over image and checked image function with jquery. I successfully made the function but didn’t work properly.

Here is my html form, using foreach. It shows different images on each divs.

        <form name='frm_edit_interest' action='/home/edit_interest' method='POST'>
            <?
                if(count($list) <= 0):
                    echo 'error';
                else:
                    $i = 0;
                    foreach($list as $row):
                        ++$i;
            ?>  
                <div class='w_select_td'>
                    <div class='w_select_title_div'>
                        <span class='w_select_title_text'><?=$row['i_keyword']?></span>
                    </div>
                    <div class='w_select_img_div'>
                        <label for="w_interest" class="imag_box_<?=$row['i_idx']?>">
                            <img src="/images/account/ws_<?=$row['i_idx']?>.png"/ style='cursor:pointer;border:solid 1px #eee;'>
                            <input name="chk[]" value='<?=$row['i_idx']?>' type="checkbox" style="display:none">
                        </label>
                    </div>
                </div>
            <?
                    endforeach;
                endif;
            ?>  

            </div>
            </div>

            <div id='w_next_btn_div'>
                <input id='btn_login' name='btn_login' type='submit' class='button' value='submit' />
            </div>
        </form>

Here is the jquery script:

<script>
$(document).ready(function () {

    var idx = idx

    $('.imag_box'+idx+' img').hover(
         function () {
             if($(this).next().val() !== "1") {
                 $(this).attr('src', '/images/account/ws_'+idx+'_hover.png');
             }
          },
         function () {
             if($(this).next().val() !== "1") {
                 $(this).attr('src', '/images/account/ws_'+idx+'.png');
             }
         }
      );


    $(".imag_box"+idx+" img").click(function() {
        if($(this).next().val() !== "1") {
             $(this).attr("src", "/images/account/ws_"+idx+"_checked.png");
             $(this).next().val("1");
        } else {
             $(this).attr("src", "/images/account/ws_"+idx+".png");
             $(this).next().val("0");
        }
    });
});
</script>

I made different images to load them based on numbers from unique index number. I saved the different image files which include numbers to load easily.

The problem is that I can’t make that when a user put their mouse over the image, the image changes automatically for right image.

So, it has to send unique index number to jquery when users put their mouse over the each image.

Can you give me a suggestion?

  • 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-01T23:26:22+00:00Added an answer on June 1, 2026 at 11:26 pm

    have you tried this, getting the index from the value field

    <script>
    $(document).ready(function () {
    
    
    
        $('.imag_box img').hover(
             function () {
                 if($(this).next().val() !== "1") {
                     $(this).attr('src', '/images/account/ws_'+ $(this).val() +'_hover.png');
                 }
              },
             function () {
                 if($(this).next().val() !== "1") {
                     $(this).attr('src', '/images/account/ws_'+ $(this).val() +'.png');
                 }
             }
          );
    
    
        $(".imag_box img").click(function() {
            if($(this).next().val() !== "1") {
                 $(this).attr("src", "/images/account/ws_"+ $(this).val() +"_checked.png");
                 $(this).next().val("1");
            } else {
                 $(this).attr("src", "/images/account/ws_"+ $(this).val() +".png");
                 $(this).next().val("0");
            }
        });
    });
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to make a JComboBox that has check boxes for items instead
I'd like to make a custom CellTree that would use checkbox based cells (I
I would like to make a CheckBox that looks exactly like a button. My
I would like my jQuery function to turn check the attribute of the checkbox
Would like to make anapplication in Java that will not automatically parse parameters used
I would like to make an entire inline formset within an admin change form
I would like to make a php script that can capture a page from
I would like to make a ListBox function like a Grid . Each time
I have a page with a form on it. I would like to make
I would like make an extension method for the generic class A which takes

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.