Note that there are some explanatory texts on larger screens.

plurals
  1. POUpdate persistent data in MySQL after using drag and drop
    primarykey
    data
    text
    <p>The scenario:</p> <p>I have a simple site with 8 square divs. In two of the divs are pictures and the other six are empty. The pictures are just a placeholder for the labeled divs in order to show who is using what physical machine.</p> <p>The two pictures are draggable and I have the following javascript to allow them to be dragged and dropped into the empty divs.</p> <p>The code:</p> <p>While its not the most elegant, I'm hoping it gets my point across.</p> <pre><code> 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"); if (ev.target.className === "active") { return; } else { ev.target.appendChild(document.getElementById(data)); if (ev.target.id === "A") { //switch the value in the database table for "A" from "0" to "1" to persist the location of the picture. //switch the value in the database table for "[dragged from]" from "1" to "0" to clear the location of the picture. } else if (ev.target.id === "B") { //switch the value in the database table for "B" from "0" to "1" to persist the location of the picture. //switch the value in the database table for "[dragged from]" from "1" to "0" to clear the location of the picture. } else if (ev.target.id === "C") { //switch the value in the database table for "C" from "0" to "1" to persist the location of the picture. //switch the value in the database table for "[dragged from]" from "1" to "0" to clear the location of the picture. } else if (ev.target.id === "D") { //switch the value in the database table for "D" from "0" to "1" to persist the location of the picture. //switch the value in the database table for "[dragged from]" from "1" to "0" to clear the location of the picture. } else if (ev.target.id === "E") { //switch the value in the database table for "E" from "0" to "1" to persist the location of the picture. //switch the value in the database table for "[dragged from]" from "1" to "0" to clear the location of the picture. } else if (ev.target.id === "F") { //switch the value in the database table for "F" from "0" to "1" to persist the location of the picture. //switch the value in the database table for "[dragged from]" from "1" to "0" to clear the location of the picture. } } } </code></pre> <p>I am unsure how to target the id for the "dragged from" divs. Any help is appreciated. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload