I have a list that I need to spell check before adding it to the database:
<table>
<tr>
<td>1-1 Some text </td> <td> 1-2Some more text</td>
</tr>
<tr>
<td>2-1 Some text </td> <td> 2-2 Some more text</td>
</tr>
<tr>
<td>3-1 Some text </td> <td> 3-2 Some more text</td>
</tr>
</table>
<button> Import list to database </button>
My idea is this, using jQuery:
When I click the text in 2-1, it will be “replaced” by a text box so that I can edit the text.
What is the bestway to achieve this?
Would I need a hidden field containing a <input type="text" field?
Would that be the easiest and most elegant way of doint it?
If you modify your markup to include the input box then when you go to replace the “static” string with the text() function you will need to work around that the element also has an input element.
A better approach may be to leave your markup as is and use jquery to swap in and out a tetxbox as needed into the cell.
So when a user clicks the cell, you do the following
1) Read the current value useing the text() function
2) Replace the current value with a newly created tag
When the user hits ENTER (or whatever other method for signifying editing is done) do the following
1) Read the current input value using val() function
2) Remove the tag
3) Put the value back in the cell using the text() function