View Full Version : link button bbcode

06-30-2004, 11:48 PM
ok just trying to get BBcode i think its called on my news admin script. As you all know it is uesed here for things like smiles and links. I have managed to get smilies working with this code which I found on the forums after a search

<script language="javascript">
var obj;
function insert(str){
if (obj){
<form name="">
<textarea name="t1" onfocus="obj=this"></textarea>
<textarea name="t2" onfocus="obj=this"></textarea>

<a href="javascript:insert(' :huh: ')"><img src="http://www.elitegnetwork.com/forums/html/emoticons/huh.gif" alt='smilie' border='0' /></a>


but what I didnt find while searching was the ability to have a link generation button where if u want to put in a link u press the button and a window pops up asking for the url and another for the url name

I have made the php so that it finds these tags (blahname (blah)) and inserts the approprite html in so the result when posted is a real html link.
So Now i am wanting to put in some javascript to help things become more user freindly

So in short how do you make a add link button like the one above while writing in the forums?

07-01-2004, 12:25 AM
Use the function and the example link below:

function url_prompt() {
var url = window.prompt("Enter the URL of the link or nothing to cancel:", "http://");
if(url) {
var url_name = window.prompt("Enter the text to be displayed for the link (this is optional):", "");
if(obj) {
obj.value+= (url_name) ? "[ url="+url+"]"+url_name+"[/url]" : "[ url="+url+"]"+url+"[/url]";

<a href="javascript:url_prompt()">Add a link</a>

Delete the white-spaces in the tags (this is only to prevent the forum from converting them.