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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:48:25+00:00 2026-05-23T06:48:25+00:00

for a school project i’m making a jigsaw puzzle out of javascript and jquery.

  • 0

for a school project i’m making a jigsaw puzzle out of javascript and jquery. I have created 4 draggable div’s that should be dropped at a point, and if all div’s have been dropped at the right place, it should give a message that the puzzle is finished. everything is finished, except the part of the message. My IT teacher told me that I have to use a counter (i++) but I can’t get this part working. Could you help?

If you have the answer, can you explain it a bit as well? I don’t have much experience with jquery/javascript.

thanks in advance, Friso (Netherlands)

the code of the important stuff(link to the page: friso.webatu.com/Site/droppable_jquery_met_javascript.htm)

<script>
var i = 0;
$(function() {

    $( ".draggable_l_t" ).draggable({ snap: ".droppable_l_t, .droppable_r_t, .droppable_l_b, .droppable_r_b", snapMode: "inner" });
    $( ".draggable_r_t" ).draggable({ snap: ".droppable_l_t, .droppable_r_t, .droppable_l_b, .droppable_r_b", snapMode: "inner" });
    $( ".draggable_l_b" ).draggable({ snap: ".droppable_l_t, .droppable_r_t, .droppable_l_b, .droppable_r_b", snapMode: "inner" });
    $( ".draggable_r_b" ).draggable({ snap: ".droppable_l_t, .droppable_r_t, .droppable_l_b, .droppable_r_b", snapMode: "inner" });

    $( ".droppable_l_t" ).droppable({
        accept: ".draggable_l_t",
        drop: function( event, ui ) {

                    i++;
        }
    });

    $( ".droppable_r_t" ).droppable({
        accept: ".draggable_r_t",
        drop: function( event, ui ) {

                    i++;
        }
    });

    $( ".droppable_l_b" ).droppable({
        accept: ".draggable_l_b",
        drop: function( event, ui ) {

                    i++;
        }
    });
    $( ".droppable_r_b" ).droppable({
        accept: ".draggable_r_b",
        drop: function( event, ui ) {

                    i++;
        }
    });

});
while (i==3)
{alert('goedzo!');}
</script>
  • 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-05-23T06:48:25+00:00Added an answer on May 23, 2026 at 6:48 am

    You need to check the value of i after you increment it. The while bit is useless right now. Try

    <script>
    $(function() {
        var i = 0;
    
        function dropCallback() {
            i++;
            if(i===4) {
                alert('goedzo!');
            }
        }
    
        $( ".draggable_l_t" ).draggable({ snap: ".droppable_l_t, .droppable_r_t, .droppable_l_b, .droppable_r_b", snapMode: "inner" });
        $( ".draggable_r_t" ).draggable({ snap: ".droppable_l_t, .droppable_r_t, .droppable_l_b, .droppable_r_b", snapMode: "inner" });
        $( ".draggable_l_b" ).draggable({ snap: ".droppable_l_t, .droppable_r_t, .droppable_l_b, .droppable_r_b", snapMode: "inner" });
        $( ".draggable_r_b" ).draggable({ snap: ".droppable_l_t, .droppable_r_t, .droppable_l_b, .droppable_r_b", snapMode: "inner" });
    
        $( ".droppable_l_t" ).droppable({
            accept: ".draggable_l_t",
            drop: dropCallback
        });
    
        $( ".droppable_r_t" ).droppable({
            accept: ".draggable_r_t",
            drop: dropCallback
        });
    
        $( ".droppable_l_b" ).droppable({
            accept: ".draggable_l_b",
            drop: dropCallback
        });
        $( ".droppable_r_b" ).droppable({
            accept: ".draggable_r_b",
            drop: dropCallback
        });
    
    });
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have multiple python files for a school project that I want to open
As a school project we've created a C# XNA 4.0 Game that runs perfectly
For a school project we have to create an evaluation website that requires a
I have a school project that i think i can do with the concept
I have this school project I'm making, where I need to make my code
This is for a school project. I have a Query<E> class that holds an
For a school project, I'm making a webapp that presents a dichotomous key .
So I have a school project that uses error(). However I'm on a Windows
I have a school project in which I have to implement a chat application,
For a school project we're developing a game that's a little like Conway's game

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.