stelthius Posted May 30, 2009 Share Posted May 30, 2009 Alright guys, Didnt know which section to post this in but it is generally a JS question, im trying to use some JS to make a bar to insert BB tags into a text area now i have some code and it works in a standard HTML doc but for the life of me i cant get it to work within my PHP doc, i've tried several methods from google over the past 2 days but i just cant get it so if anyone can help id be greatfull, here is my JD code : function addText(Text) { var obj = document.send.message; obj.focus(); if (document.selection && document.selection.createRange) // Internet Explorer { sel = document.selection.createRange(); if (sel.parentElement() == obj) sel.text = Text; } else if (obj != "undefined") // Firefox { var longueur = parseInt(obj.textLength); var selStart = obj.selectionStart; var selEnd = obj.selectionEnd; obj.value = obj.value.substring(0,selStart) + Text + obj.value.substring(selEnd,longueur); } else obj.value += Text; obj.focus(); } function addTags(Tag, fTag) { var obj = document.send.message; obj.focus(); if (document.selection && document.selection.createRange) // Internet Explorer { sel = document.selection.createRange(); if (sel.parentElement() == obj) sel.text = Tag + sel.text + fTag; } else if (obj != "undefined") // Firefox { var longueur = parseInt(obj.textLength); var selStart = obj.selectionStart; var selEnd = obj.selectionEnd; obj.value = obj.value.substring(0,selStart) + Tag + obj.value.substring(selStart,selEnd) + fTag + obj.value.substring(selEnd,longueur); } else obj.value += Tag + fTag; obj.focus(); } Here is my button function : <a title="Bold : [b ][/b ]" onmousedown="addTags(\'[b ]\',\'[/b ]\')" style="background-color:#F7F7F7; font-size:10pt; border: outset white 1px;"> <b>B</b> </a> And here is my text area that im trying to insert the BB tags into : <textarea wrap="VIRTUAL" name="message" cols="50" rows="10" value="'.$my_content.'"></textarea> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.