Forum Moderators: open

Message Too Old, No Replies

Using Java within PHP

         

stelthius

10:10 am on May 30, 2009 (gmt 0)

10+ Year Member



Hello all.

Ok i have some JS i need to use in my PHP file to insert BBcode into a text area but it sems no matter what i try my JS wont work inside PHP it works in a regulair HTML file...

Any help is appretiated.

Below is my JS

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();
}

Below is what im using to input the BB tags into the textarea

<a title="Bold : [B ][/B ]" onmousedown="addTags(\'[B ]\',\'[/B ]\')" style="background-color:#F7F7F7; font-size:10pt; border: outset white 1px;">&nbsp;<b>B</b>&nbsp;</a>

Many thanks rick

stelthius

12:08 pm on May 30, 2009 (gmt 0)

10+ Year Member



Never mind i solved it using a old method.

whoisgregg

5:39 pm on May 30, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld, stelthius!

Glad you got it sorted. :) Would you be willing to post your solution for someone else who may have the same problem and find this thread?

stelthius

12:50 pm on May 31, 2009 (gmt 0)

10+ Year Member



Certainly i echo'd the JS using

<?php
echo <<<JavascriptCode

JS CODE HERE INCLUDE ALL NORMAL TAGS

JavascriptCode;
?>

Old method i guess.