useradd
more /root/Forums and Website/BBCode Buttons?.thread
Can you add buttons to wrap text in bbcode?
Code
<script> function tag(t1,t2) { var o = document.getElementById('ted'); if (o.setSelectionRange) { o.value = o.value.substring(0,o.selectionStart) + t1 + o.value.substring(o.selectionStart,o.selectionEnd) + t2 + o.value.substring(o.selectionEnd,o.value.length); } else { var range = document.selection.createRange(); range.text = t1 + range.text + t2; } o.focus(); } </script> <input type="button" value="B" onclick="tag('[b]','[/b]');" /> <input type="button" value="I" onclick="tag('[i]','[/i]');" /> <input type="button" value="U" onclick="tag('[u]','[/u]');" /> <br /><textarea id="ted" cols="30" rows="5"></textarea>
Notice, the above code doesn't work the best in IE. Actually, it does work in IE, but it doesn't restrict itself to the textarea. That is, if you were to select some text outside of the textarea, such as someone's post, and then click the button, it would actually put [b] and [/b] tags around the selected text... Which is a really neat effect, but not desirable...
Code
<script> function tag(t1,t2) { var o = document.getElementById('ted'); if (o.setSelectionRange) { o.value = o.value.substring(0,o.selectionStart) + t1 + o.value.substring(o.selectionStart,o.selectionEnd) + t2 + o.value.substring(o.selectionEnd,o.value.length); } else { var range = document.selection.createRange(); range.text = t1 + range.text + t2; } o.focus(); } </script> <input type="button" value="B" onclick="tag('[b]','[/b]');" /> <input type="button" value="I" onclick="tag('[i]','[/i]');" /> <input type="button" value="U" onclick="tag('[u]','[/u]');" /> <br /><textarea id="ted" cols="30" rows="5">
Eeer.... What was that supposed to do?
He asked if I can. I showed him that I partially can. Nobody asked to implement it :-p
besides, as mentioned above, that code is buggy, so anybody with workarounds is encouraged to post their revision or suggested revision to it.
besides, as mentioned above, that code is buggy, so anybody with workarounds is encouraged to post their revision or suggested revision to it.
please implement that, that would be really usefull, you could also add smilies(you can host them at flickr, direct linking is posible)
I don't think it's a good idea to implement it because it does funky things in IE. If someone can make a revised version that doesn't have the problems, then I'll implement it.