0
I need to do a drag-and-drop that looks like the image below, which is the system I’m developing.
In the buttons referring to "1st Period", "2nd Period" and others, I put a function that returns the disciplines referring to the period informed.
Example of table http://associacaoeua.com.br/particular/img/horario.png code =
<td><type="button" onClick="disc('1');">1º Periodo</button></td>
I activated the drag on the return of the disciplines, so I can drag you to the desired day and time with:
draggable="true" ondragover="allowDrop(event)" ondragstart="drag(event)">
when I release the discipline in a particular location I can get the code (ID) from it follows code I used:
function drag(ev) {
revert:true,
ev.dataTransfer.setData("Text", ev.target.id);
}
function drop(ev) {
ev.preventDefault();
var data = ev.dataTransfer.getData("Text");
ev.target.appendChild(document.getElementById(data));
//o id da disciplina esta na variavel data.
alert(data);
//data é o ID
}
I can save in the bank using Ajax, what I can’t do is take the day and time of class. I’m just getting the ID of the class.
Once discipline is unleashed I must have in
function drop(ev) {
*var id : ja tenho.*
var dia : ex.. SEGUNDA.
var hora: ex.. 6:10 a 7:40
}
How should I do it?
What is your question? Please edit your question by clarifying what your specific problem is (is drag and drop? is to send the data to the server? is to save in the BD?), what have you done so far (with excerpts of preferred code), and what is causing you difficulty.
– mgibsonbr
@user4870 I gave a general edited, why was not giving to understand. If it is wrong, just edit there...
– user2692
Do you want to move the cells or the table? Move to where?
– lionbtt
Dei -1, your question is very vague and full of questions. It is not clear.
– Luiz Picolo
I think this question could be divided into 2 questions, one asking how to create a drag-n-drop in HTML, making use of javascript and the other of how to save data from an HTML component sorting in the DOM, in a database.
– Gabriel Gartz
This Html5rocks tutorial can help you http://www.html5rocks.com/pt/tutorials/dnd/basics/
– fernandoandrade
That’s much better! I voted to reopen, @Luizpicolo, take a look too.
– Sergio
Now the question is clearer, topic re-opened.
– Gabriel Gartz
Now you have more content. I withdraw my -1
– Luiz Picolo