1

I have to make a page with a huge table of data, and it has to be editable. The problem is, some of the fields are supposed to be very long (hundreds of characters), and I need some sort of way to enter this text without disrupting the table's layout, but showing the users the entire text while they're typing.

A good solution would be something that looks just like a vanilla 1-line text box which, when clicked, slides out, pretty much like a <select>, lets the user type in all the text he wants, and then shrinks back to text box size when the user clicks away.

I'm sure there must be something like that for jQuery, but I just can't find it.

Here's how it should act:

https://i.sstatic.net/PMzbN.png

3 Answers 3

1

Here's what I figured out playing around with some javascript

http://jsfiddle.net/bsWy6/

You can mess with the styling until it is exactly what you want. I think it's pretty close to what you're looking for though.

I am assuming you are populating your table from a database? If that's true, I would use php to generate the id's so that you don't have to type them for every single row, since your functions need to know the exact cell it's working with. If you want help with that code too, just let me know and I'll post it up here. I'm just not sure if you've done anything with php, so I don't want to go into all of it if you don't want it.

Good luck!

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

Comments

1

I think NicEditor will fit the need. See their inline editing demo.

3 Comments

Looks nice, thanks, but the boxes it creates don't return automatically to 1-line size, so the table would be pretty much ruined.
it is amazing, I don't know how, but ctrl+z really undo the last action
But it gets rid of the entered text! This is how it should act: http://i.imgur.com/TY5tk.png
0

For each cell, make two fields:

<td id="td-1-2">
    <p id="p-1-2">Some text to...</p>
    <textarea id="ta-1-2">Some text to...</textarea>
</td>

Then hide the <textarea> and show the <p>. When the user clicks the <p> then hide the <p> and show the <textarea>. Either put a submit button below the textarea or save its contents when it looses focus.

Comments

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.