Re: Restored tables in read-only mode
Posted by:
Shay _Fox
Date: February 12, 2016 02:25PM
I have three approaches, Here you can use both <input> or <textarea> as per your requirements.
1. Use Input in <td>.
Using <input> element in all <td>s,
<tr><td><input type="text"></td>....</tr>
Also You might want to resize the input to the size of it's td. ex.,
input { width:100%; height:100%; }
2. Use contenteditable='true' attribute. (HTML5)
But if you want to use contenteditable='true' you might also want to save the appropriate values to the database. you can achieve this with ajax.
You can attach keyhandlers keyup, keydown, keypress etc to the <td>. Also it is good to use some delay() with that events when user continuously types, the ajax event won't fire with every key user press. for example,
$('table td').keyup(function() {
clearTimeout($.data(this, 'timer'));
var wait = setTimeout(saveData, 500); // delay after user types
$(this).data('timer', wait);
});
function saveData() {
// ... ajax ...
}
3. Append <input> to <td> when it is clicked.
Add the input element in td when the <td> is clicked, replace it's value according to the td's value. When the input is blured, change the td's value with the input's value. All this with javascript.
Subject
Written By
Posted
February 12, 2016 05:31AM
February 12, 2016 09:41AM
Re: Restored tables in read-only mode
February 12, 2016 02:25PM
February 19, 2016 11:21PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.