Content where your pointer is

  • tastysite
  • Proficient
  • Proficient
  • User avatar
  • Posts: 349
  • Loc: Brighouse, West Yorkshire, England

Post 3+ Months Ago

Hi have a text box (rather like this one on ozzu and infact most forums) that uses BBcode now when you click a button say bold it will place the bbcode for bold which is translated into xhtml using a php repalce but thats not inportant, here is the thing it places the tags at the end of the content because I am using this javascript code.
Code: [ Select ]
<script type="text/javascript">
 
function add_bold(elementID){
var content = document.getElementById(elementID).value;
document.getElementById(elementID).value = content + '{b}{/b}';
document.getElementById(elementID).focus();
}
<script>
  1. <script type="text/javascript">
  2.  
  3. function add_bold(elementID){
  4. var content = document.getElementById(elementID).value;
  5. document.getElementById(elementID).value = content + '{b}{/b}';
  6. document.getElementById(elementID).focus();
  7. }
  8. <script>

{} = []
how would I modify it to place the tags where the pointer is and also if you select something I want it to place the tags on each side to the content, so what I want is just like it is here rely.
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13502
  • Loc: Florida

Post 3+ Months Ago

Here's the JS Ozzu uses for phpBB3,
styles/light/template/editor.js

There's a function called "insert_text" in that file which should get you on the right track.

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 79 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.