<input id="strk" type="button" onclick="document.getElementById('pbody').value+='[S][/S]'; return false;" value = " S " /> I understand that +
.value+='[S][/S]' inserts text (BB code) at the end of the text. And how to make the insertion take place at the current cursor position?
How to make the insert "framed" the selected text in the form?
More: When writing text in the form, the user clicks on the button and need:
- insert the BB code into the cursor position
- If the user selected the text to enter it into the BB code, you need to insert the beginning of the code - before the selected text, the end of the code - at the end of the selected text. That is, insert the selected text in the BB code.
1 and 2 do not need to be made in one decision (it is easier for me to understand).
