...

View Full Version : Need Help with BBCode



Bry Man
09-19-2005, 12:20 AM
Hey

Ive been trying for days now to get a bbcode panel on my site for putting bbcodes and stuff into comment boxes since I have user inputted html striped from the comments, but so far ive had absolutely no luck. Ive tried several scripts but nothing seems to give any results. I just did a search on the Javascript forums here and tried a few of the 'working' scripts but they didnt work either. Here is the lastest one that i tried.


<html>
<head>
<script language="javascript">
var obj;
function insert(str){
if (obj){
obj.value+=str;
obj.focus();
}
}
</script>
</head>
<body>
<form name="">
<textarea name="t1" onfocus="obj=this"></textarea>
<textarea name="t2" onfocus="obj=this"></textarea>

<a href="javascript:insert(' :huh: ')">wee</a>
</form>
</body>
</html>

I have very little Js know how but Im aiming to learn, but this has me stumped...apparently it should work but it doesnt...could it be because im using FF...like i said, i dont know much about Js...if anyone can help me youd be saving me alot of frustration and I would greatly appreciate it, Ive got the php side of the bbcode script down, just the part where you click the link and the code is put into the text area is whats killing me =S

rwedge
09-19-2005, 12:51 AM
Not sure if this is what you are after
<html>
<head>
<script type="text/javascript">
var obj;
function insert(str){
if (obj){
document.getElementById(obj).value+=str;
document.getElementById(obj).focus();
}
}
</script>
</head>
<body>
<form name="a1">
<textarea name="t1" onfocus=obj='t1'></textarea>
<textarea name="t2" onfocus=obj='t2'></textarea>

<a href="javascript:insert(' :huh: ')">wee</a>
</form>
</body>
</html>

Bry Man
09-19-2005, 03:10 AM
That code doesnt do anything either =S...does it work for you? is it a me thing lol?

rwedge
09-19-2005, 04:34 AM
Try it with id, I used IE and it didn't mind just the name

<html>
<head>
<script type="text/javascript">
var obj;
function insert(str){
if (obj){
document.getElementById(obj).value+=str;
document.getElementById(obj).focus();
}
}
</script>
</head>
<body>
<form name="a1">
<textarea name="t1" id="t1" onfocus=obj='t1'></textarea>
<textarea name="t2" id="t2" onfocus=obj='t2'></textarea>

<a href="javascript:insert(' :huh: ')">wee</a>
</form>
</body>
</html>

Bry Man
09-19-2005, 04:54 AM
It still doesnt work with me :confused: I tried in both IE and Firefox....so very odd



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum