This does not work in IE10 but it does in other browsers: http://jsfiddle.net/54EKK/2/
If you enter text in the textarea and set the variable, the variable retains the contents of the textarea.
Of course if you set the variable before adding content (outside of the function) it will be empty, but in my project I can not do that. Here is a demo of that. It works in all browsers: http://jsfiddle.net/54EKK/3/
Now my question is if there is a way to empty the textarea while still keeping the variable in the function. BTW emptying the value does not help either.
Thanks for your insights guys!
(I am afraid of not being clear in how I explained things so please tell me if not!).
As far as I can tell, that only works in IE9. I have tried Firefix, Chrome, Safari and Opera, and neither gets you the
textareacontent when usinginnerHTML.When you use
innerHTML, that will give you thevalueattribute, which is the original text that was set in the form field. The value that you type into the form field is in thevalueproperty.If you want the content of the form fields when using
innerHTML, you have to copy the value property into the value attribute for each form field.Edit:
As your clarified that what you really want is to just clear the
textarea, then set the value of thetextareaelement to an empty string.You need to access the element, so you might want an id on it:
Then when you want to clear it, you get the reference to it and clear the value: