Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

JavaScript HTML5 Canvas - Drag and Drop

WolfTech77

New Coder
Hello!

I am attempting to create an HTML5 Canvas with Drag and Drop. I got the dragging to work, but I would like to be able to drop my three objects in a box, then click a "Check" button which will show "correct" or "incorrect" depending the order in which they were dropped. I'm also using Adobe Animate. Much help is needed. Please point me in the right direction if possible.


Thank you!
 
Hello WolfTech77!

I do not know how to help here, your question is relatively large. If you are comfortable with JS it does not seem too hard to do, but it for sure takes some time to actually code.
Some thoughts, I do not know if it will be useful to you?:
You can generate <input type="checkbox"></input elements for each dragged element and then link a function to the event when a check-box is checked so you can execute the verifications and display the appropriate message.
 
Hello!

I am attempting to create an HTML5 Canvas with Drag and Drop. I got the dragging to work, but I would like to be able to drop my three objects in a box, then click a "Check" button which will show "correct" or "incorrect" depending the order in which they were dropped. I'm also using Adobe Animate. Much help is needed. Please point me in the right direction if possible.


Thank you!
Hey Wolf,

I do believe w3schools has exactly what you need :)


Here is the code they suggest, for a simple drag n drop:


function allowDrop(ev) {
ev.preventDefault();
}

function drag(ev) {
ev.dataTransfer.setData("text", ev.target.id);
}

function drop(ev) {
ev.preventDefault();
var data = ev.dataTransfer.getData("text");
ev.target.appendChild(document.getElementById(data));
}
 
Back
Top Bottom