0

I've been trying to create a table created by JavaScript. I finally found a way to create the table, but I lack the knowledge to put an input tag and a form into this table

var table = document.getElementById("myTable");
var row = table.insertRow(0);
var cell1 = row.insertCell(0);
 var cell2 = row.insertCell(1);
cell1.innerHTML = "Replace this with other input";
cell2.innerHTML = "Replace this with input";

The style is irrelevant, I have all the code I need behind that

1 Answer 1

1

The Solution:

var table = document.getElementById("myTable");
var row = table.insertRow(0);
var cell1 = row.insertCell(0);
 var cell2 = row.insertCell(1);

var input1=document.createElement('input');
input1.setAttribute('type','text');
input1.value='input1';

var input2=document.createElement('input');
input2.setAttribute('type','text');
input2.value='input2';


cell1.appendChild(input1)
cell2.appendChild(input2)
<table id="myTable"></table>

Sign up to request clarification or add additional context in comments.

1 Comment

How do i set the method that it uses (e.g POST)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.