How do I Maintain Whitespace When saving data from <textarea>?
Posted on 2007-10-01
My client has a form with several memo fields on it that are currently implemented as <input type="text"> The actual size ranges from 60px wide up to 500px wide. All are a single "line". My client wants me to put a small button or inline image next to each that will bring up a popup window with all the text from the memo field. (That part was pretty easy and it works great.) I am using a <textarea> in the popup and am copying the text in the textarea back to the parent window <input> when a button (in the popup) is clicked. I am getting text to copy back but the problem is that all white space is stripped out when it gets stuffed in the input box.
What can I do to get the data to go from the textarea on the popup to the input box on the form while maintaining whitespace? I figure that when I update the database from the form that I will have to "escape" the text and then when I pull the data out and populate that field I will have to "unescape" it but, what about between the <input> on the parent and the <textarea> on the popup?
If I left something critical out, please don't hesitate to ask. Thanks in advance for the help.