Jump to content

The buttons in the Forum


liam1412

Recommended Posts

I'm back again

I have written BBcode for my forum but don't want people to have to manually type the :-) or whatever.  How do I create the buttons such as the ones used in this forum that input the ;-) into the post as itis being typed.  This may not even be php but im not ure how its done.

Thanks
Link to comment
Share on other sites

You need to use javascript. Like add a button

<input type="button" onclick="link()" />
<textarea id="text"></textarea>

and add some JS at the top

function link ()
{
var link = prompt ("Enter URL:", "")
if (link!="") var text = prompt ("Enter text:", "");
document.getElementById('text').value=document.getElementById('text').value+"[link=\""+link+"\"]"+text+"[/link]"
}

but that just adds it at the end of the text..I can't remember how to add it where you're typing, and if you want to highlight text and then click the button, it's a bit more complex.
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.