Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Advanced edit boxes

Status
Not open for further replies.

TheFoxy

Programmer
Nov 22, 2002
48
GB
Hey,

How would I go about adding one of those natty little edit boxes to a webpage you see in forum 'Add Reply' pages? (The ones that have buttons that add text into the box). The best example is the PHPbb reply box, this has loads of buttons above the box which add tags, smilies, etc. (I assume it uses Javascript as Javascript is mentioned if you hover over a button I think, but how is a mystery to me).

Two other things:
1)These boxes with the buttons always dump the text they add to the box at the end of the current text, not where the cursor is. Is there any way to get the text to put itself at the cursor's position?

2) PHPbb also has a seperate window with smilies that can be opened out, and a smilie can be clicked to add it to the edit box in the original window (a seperate window). How is this done???
 
It can get complicated. The current cursor position is, in fact, clicking a button up above!

Hm, if I were doing this, I'd declare a variable CursorPosition. It would contain an integer and be the position in the text string.

I would update CursorPosition on every keyup or onchange event in that textarea.

When I wanted to insert, I'd pull the textarea content into two different variable, that which is [0..CursorPosition] and that which is [CursorPosition+1..textarea.value.length].

Then textarea.value = SplitValue1 + Addition + SplitValue2

That might help.

However, the first thing I'd do is see if I could find something in a script archive. [lol]

Cheers,


[monkey] Edward [monkey]

"Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!" -- inventor of the cat door
 
Hey Foxy

Have you tried the editor at; ?

it doesn't do the JavaScript thing quite the way you like but you can insert images into any part of the text area.

It also gives you a design view and an html view. I havn't used it yet in any of my apps but the demo is very impressive. If you use it let me know how you get on.

Thanks

MrBelfry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top