Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

248
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!