Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

250
Vistas
Drag and drop a button into a table

Im new to JS and HTML, but I hope this doesnt sound dumb now. Ive got a list on the right side where a bunch of buttons are shown which I want to be able to drag and drop them into the empty table on the left side.

What I done already:

With the code I got atm i get this error

Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'

So I already found that the method is returning a string instead of a node element and this method can only append elements with that type. So how do I move the input as a node element? Are there better ways to do that?

JavaScript:

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

function drag(event) {
  event.dataTransfer.setData("text", event.target.id);
  console.log(data);
}

function drop(event) {
  event.preventDefault();
  var data = event.dataTransfer.getData("text");
  event.target.appendChild(document.getElementById(data).value);
  console.log(data);
}

Script for the button list

@foreach (var t in ct.cases)
{
<div class="database-cases" data-tooltip="@t.Title" draggable="true" ondragstart="drag(event)" id="dragbutton">
  <input class="database-cases-id btn btn-link" type="button" value="@t.IdText" onclick="" />
  <sub class="database-cases-title">@t.Title</sub>
</div>
}

Table:

<table class="overallTable" summary="Layout" ondrop="drop(event)" ondragover="allowDrop(event)" id="dropzone"></table>
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda