Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
JavaScript: Retrieve the text in a textarea
-
Hello,
I am using a workflow in Editorial to generate and preview html code.
In my code, I have a textarea (embedded in two div, if this matters) and I need to get the text of the textarea when the user "clicks" on a specific button.
In JavaScript this is usually done with document.getElementById(obj).value, but this does not work in Editorial. I have tried also innerHTML, and as expected it does not work as well.
In the same script, I can successfully use document.getElementById(obj).style.display or document.getElementById(obj).name, so the problem is in "value".Any hints? Any way to get the textarea content?
Thanks,
Maurizio -
I found the problem and in fact document.getElementById(obj).value works as it should.
I am getting an empty result because in the textarea there is markdown code with a leading "#", and everything after the hash is not captured.Can anyone help with this?
-
If you are passing this via a uri of some kind, you need to use
encodeURIComponent
To escape the various characters that are special in uRIs.
-
Thanks JonB,
this has solved the problem.
Cheers