Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Stephen Gillon
11,996 PointsWant to program drag and drop items to accept correct answers in different categories with submit button
Programmed drag and drop items and categories just don't know the first thing on how to to program correct and incorrect combinations.
2 Answers
Stephen Gillon
11,996 PointsUpdated to the right formatting Jacob Mishkin .
Jacob Mishkin
23,118 PointsI would look into using conditional statements to start. Not really sure what you are trying to do, but I think an if statement might help. And Please do not have it minimized.
Stephen Gillon
11,996 PointsThanks for the advice Jacob. Here's some of the code I'm having issues with. I have"users" as my draggables and the droppable zones as my divs:
<section id="user-levels">
<h1>Drag and Drop Quiz</h1>
<div id="unassigned" ondrop="dropUser(this, event)" ondragenter="return false" ondragover="return false">
<h2>Choices</h2>
<!--These are all the draggable peices-->
<a draggable="true" class="user" id="NetBEUI" ondragstart="dragUser(this, event)">NetBEUI</a>
<a draggable="true" class="user" id="IP" ondragstart="dragUser(this, event)">IP</a>
<a draggable="true" class="user" id="AppleTalk" ondragstart="dragUser(this, event)">AppleTalk</a>
<a draggable="true" class="user" id="DECnet" ondragstart="dragUser(this, event)">DECnet</a>
<a draggable="true" class="user" id="BGP" ondragstart="dragUser(this, event)">BGP</a>
<a draggable="true" class="user" id="RGIP" ondragstart="dragUser(this, event)">RGIP</a>
<a draggable="true" class="user" id="RIP" ondragstart="dragUser(this, event)">RIP</a>
</div>
<div id="routed" ondrop="dropUser(this, event)" ondragenter="return false" ondragover="return false">
<h2>Layer 3 Routed Protocols</h2>
</div>
<div id="routing" ondrop="dropUser(this, event)" ondragenter="return false" ondragover="return false">
<h2>Layer 3 Routing Protocols</h2>
</div>
<input type="submit" value="Submit Answers" class="sub">
<div class="clear"></div>
</form>
So far, starting my conditional statement as follows but now I'm stuck:
var routed = #routed
var routing = #routing
if(#routed === "NetBEUI", "IP", "AppleTalk"){
onclick(submit);
}
//correct answers for "routed" id div
Jacob Mishkin
23,118 Pointsunfortunately I can't read your code. Can you please format it, so we can take a look at it.