Page 1 of 1
Textfield
Posted: Sun Sep 03, 2006 3:17 am
by Miha
Hi!
I have an input textfield and i would like to make a couple of buttons, one to add bold tag around text highlighted in a text field, another to add URL tag around highlighted text. For example like on this forum, when you are posting a new topic or reply. How is this done??
regards Miha.
Posted: Sun Sep 03, 2006 8:09 am
by bmcewan
It is called BBCode, might be worth checking
http://www.google.co.uk/search?hl=en&q= ... gle+Search or indeed this article i found in the search
http://www.sitepoint.com/article/bb-cod ... pplication.
You should have some pointers here, if you get stuck, post some code and we'll try to help you out and point you in the right direction.
Posted: Sun Sep 03, 2006 12:30 pm
by Miha
bmcewan: not quite what i was looking for, but thanks anyway!
I guess i wasn't clear enough....i'm just looking for the functionality, if you highlight a part of a string in a input textfield and you click on a button, it will add some predefined substring before and after highlighted text....
So: I drag a mouse over some text, click on a button, and it will automaticly add '<b>' before, and '</b>' after that highlighted part of text...
I guess i would have to write a function, that will get the string from that textfield, find out the position where the highlighted part of a string in that textfield starts and where is stops. Than redefine that string -> add </b> at stop position, and add <b> at start position. Than return redefined text to that textfield...That's my teoretical pseudo-code-idea....i have no experience in php, so I have no idea if this is posible and no idea how to implement this thing in php.... I hope you guys can advise me how to implement this idea and what functions might be useful to me.
regards, Miha.
Posted: Sun Sep 03, 2006 1:22 pm
by feyd
You seem to be describing a WYSIWYG input such as TinyMCE, unless you visually want to see the tag code. In that case, look at the post building code used by the forum. It's all in the pages.
Posted: Sun Sep 03, 2006 3:04 pm
by Miha
Actually i don't need WYSIWYG. I don't mind to see this tags... I checked TinyMCE, it's almost what I'm looking for, it's just a bit too complex. I only need to simplify inputting text for an "almost-computer-illiterate secretary" when she is posting news on a site. Now she has to put(write) <b> and </b> tags manualy, OK sometimes she manages to write this right, but i don't want to mention, when she needs to write <a href="www.something.si">www.something.si</a> ...that's the real problem.

There are allways some typos here. Anyway...she is only allowed to add these two tags, because of page graphical design restrictions. Tiniest TinyMCE still has at least 5 options. What's better: customize TinyMCE, or develop this from scratch? Will i end up drinking if i try any of these?
BTW: feyd: I can't find that post that you were talking about. Maybe that post can answer all my question.
Posted: Sun Sep 03, 2006 3:07 pm
by feyd
The post building page I'm referring to is the one you type your messages in to post.
posting.php?mode=reply&t=54863 for this thread's for instance.
Posted: Sun Sep 03, 2006 3:14 pm
by Miha
Oh OK i got it, a little misunderstanding.
