How to implement through JavaScript when you click the corresponding cell, the text in the cell becomes editable input or select, leaving the cell and then the text in the cell is the modified text.
I do this by clicking the cell into input, not knowing how to restore the text state after the other cells, and how to return the value modified after the input. Is there a better way to achieve this effect.
<script language= "JavaScript" > Window.attachevent ("onload", gettable); function GetTable () {for (i=0; i<tbl.cells.length; i++) {var cell = Tbl.cells[i]; Cell.attachevent ("onmousedown", gettexttoinput); } gettexttoinput = function (evt) {var input; var html evt = (evt)? EVT: ((window.event)? Window.event: "") if (evt) {var cell = (evt.target)? Evt.target:evt.srcElement; For (i=0 i<tbl.cells.length; i++) {if (tbl.cells[i] = = cell) {html = ' <input type= ' text "Value=" ' + Tbl.cells[i].innertext + ' "> ' tbl.cells[i].innerhtml = html; }} </script> <table border= "1" cellpadding= "0" cellspacing= "0" id= "tbl" > <tr> &L t;td>123</td> <td>456</td> </tr> <tr> <td>abc</td> <td>efg</ Td> </tr> </table>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
2,
<script language= "JavaScript" > Window.attachevent ("onload", gettable); function GetTable () {for (i=0; i<tbl.cells.length; i++) {var cell = Tbl.cells[i]; Cell.attachevent ("onmousedown", gettexttoinput); } gettexttoinput = function (evt) {var input; var html evt = (evt)? EVT: ((window.event)? Window.event: "") if (evt) {var cell = (evt.target)? Evt.target:evt.srcElement; For (i=0 i<tbl.cells.length; i++) {if (tbl.cells[i] = = cell) {html = ' <input type= ' text "id=" input ' +i+ ' "value=" ' + Tbl.cells[i].innertext + ' "onblur=" this.parentnode.innerhtml=this.value; "onkeydown=" if ( window.event.keycode==13) {this.parentnode.innerhtml=this.value;} " > ' tbl.cells[i].innerhtml = html; Window.settimeout (' document.getElementById ("input ' +i+ '). focus (); ', 300; }} </script> <table border= "1" cellpadding= "0" cellspacing= "0" id= "tbl" > <tr> <td>123</td> <td>456</td> </tr> <tr> <t d>abc</td> <td>efg</td> </tr> </table>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]