I have this javascript function that puts a double --- quote ---- which people can use on the site. My goal is to replace the —quote— with a image or a blockquote (styled with CSS) that I already have. So if someone clicks on the button, they have to get a quote image or blockquote, which would be visible on the textarea. The problem is that I can’t get it working.
<input type="button" onclick="hen('d','--- (<? echo $language[quote2] ?>: <? echo $language[quote] ?>) ---\n\r','\n\r--- (<? echo $language[quote2] ?>: <? echo $language[quote] ?>) ---\r')" value="- <? echo $language[quote] ?> -" />
This is what I tried for example, which did not show the button anymore.
<input type="button" onclick="hen('d','--- (<blockquote id="entry"><? echo $language[quote2] ?>: <? echo $language[quote] ?></blockquote) ---\n\r','\n\r--- (<? echo $language[quote2] ?>: <? echo $language[quote] ?>) ---\r')" value="- <? echo $language[quote] ?> -" />
How can I make it work my friends?
Well, I can tell you why the button is disappearing at least. You’re breaking out of the onclick attribute by listing the blockquote id within double quotes. Try this and see where it gets you:
Although if you’re trying to insert HTML elements into a Textarea, I do not believe that is possible. You may want to try using a
<div contenteditable="true"></div>instead (of course, that will only work in browsers that support the contenteditable attribute.