Jump to content

[SOLVED] Little JS / PHP question


stelthius

Recommended Posts

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>

Link to comment
https://forums.phpfreaks.com/topic/160255-solved-little-js-php-question/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.