Working with editable table cells

81 Views Asked by At

My code edits a table cell by clicking on it. But I want to add a datalist to make it easier. It should be something like an autocomplete text. Can I add a datalist to this code? I want to see the datalist when I do edits on the names.

<td title="Workername">
<div id ="datalist" onclick="makeElementEditable(this)" 
onblur="updateWorkers(this,'<?php echo $row['taskid'] ?>')"> 
<?php echo $row['name'];  ?></div>


              <datalist id="datalist">
                <option value="test2">
                <option value="test3">
                <option value="test4">
                <option value="test5">
                <option value="test">
              </datalist>
       </td>

To make element editable:

function makeElementEditable(div){
    div.style.border = "1px solid lavender";
    div.style.padding = "5px";
    div.style.background = "white";
    div.contentEditable = true;
}

So what are your suggestions?

0

There are 0 best solutions below