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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.