+ 1
How reply button works in sololearn?
whenever we click a reply button, the name of the person to whom we wanna reply to gets pre-populated in the text area. How this works? I wanna achieve the same functionality in HTML textarea. Is it possible?
10 ответов
+ 4
Sandeep,
I see, well, if you only want to see a name in the textarea then Akshay has a working example.
But I'm not sure whether a textarea can contain hyperlink in the text, that is if you want the person name to act as hyperlink like mentions in SoloLearn : )
+ 2
Yes you can do something similar. If running on SoloLearn, the program can not exit to remember data. If running elsewhere, you can store the data in Cookies.
SoloLearn's data is proprietary and you have agreed to not reference it without their consent.
+ 2
Ipang what I wanna do is pre-fill the textarea in html with some text to be precise.
https://code.sololearn.com/W163lFcw9oPy/?ref=app
Currently, this textarea is empty.
+ 2
Sandeep you can achieve this by using innerHTML property of textarea element.
Like this
https://code.sololearn.com/WYynxAoNVmeD/?ref=app
+ 2
Sandeep I am answering your question here which you have asked in comment of the code.
Yes Ipang , textarea cannot contain any other HTML element inside it.
But there is a way to do so by setting attribute value of `contenteditable` to true of a div tag. And now we can add other HTML element in it also.
Sandeep, In the code now you can see the name appear in bold and other text as normal.
(I have modified my previous code)
But I am not sure it is a good practice or not? 🤔
+ 2
thanx :]
+ 2
You need css and javascript to make buttons work. html is only to create the elements, css to style, and javascript to code the functions
+ 1
Can you add a link to your code in post's Description above? it would help others to better understand what you are trying to achieve, how you're doing it, and what needs to be corrected.
https://www.sololearn.com/post/75089/?ref=app
+ 1
Sandeep no need of adding more element you can just change contenteditable to false. So the div just behave as a normal div with containing a hyperlink text.
Check the code again: https://code.sololearn.com/WYynxAoNVmeD/?ref=app