Closed Thread Icon

Preserved Topic: insert text into a textare(form) Pages that link to <a href="https://ozoneasylum.com/backlink?for=18044" title="Pages that link to Preserved Topic: insert text into a textare(form)" rel="nofollow" >Preserved Topic: insert text into a textare(form)\

 
Author Thread
911
Paranoid (IV) Inmate

From: Stuttgart, Germany
Insane since: Apr 2001

posted posted 07-31-2001 12:24

hi all!

i´ve got a small question. is there a way to modify my example, so that i can insert something in the middle of the text. at the moment the inserted text appears only at the end of the text.(--> because i use this: 'revisedMessage = currentMessage+addText;')

thx for your help!


lallous
Paranoid (IV) Inmate

From: Lebanon
Insane since: May 2001

posted posted 07-31-2001 13:02

You might want to ask how can i get the cursor position from a textarea object.
after that you can do some string manipulation and then insert your text in between.

btw, your link doesn't open in IE, you didn't close the TITLE tag correctly.


911
Paranoid (IV) Inmate

From: Stuttgart, Germany
Insane since: Apr 2001

posted posted 07-31-2001 13:29

sorry, i fixed the bug. ;-)

yes, that´s what i wanna do! but how?


Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 07-31-2001 14:22

Dunno if this will help, but I'm trying to reverse engineer this: http://www.dawzz.com/htbld/build2.htm for a content management system I'm working on. The formatting commands DO work in the middle of the boxes like you want.

Hope this helps!

"It takes months to find a customer, more than 5 seconds of load time to lose one."

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 07-31-2001 14:25

To get a piece of a string, use

String.substr(start,length)

or

String.substring(start,end)

Then you can take a peice of the beginning of the string, add in what you want to add, and then add on the rest of the original string. The tricky part is figuring out where the cursor is.

911
Paranoid (IV) Inmate

From: Stuttgart, Germany
Insane since: Apr 2001

posted posted 07-31-2001 16:23

Pugzly: Cool, thats what i´m looking for, but i think its really hard to reverse engineer that code. I´ve got a big problem with understanding the code. But i will work on it. And please post your solution here, if you got it.


Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 07-31-2001 17:19

911 -

Will do. I'm trying to add the basic 'editor' functions to a web based CMS solution for a portal type site. That was the only example I could find that lets you highlight text, and format it in the middle of the content, as opposed to the end. I'm sure someone around here can post a shorter, cleaner example. But for now, that's all I've got.

I'll keep ya posted.

"It takes months to find a customer, more than 5 seconds of load time to lose one."

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 07-31-2001 17:42

You have to use text ranges. Take a look at this topic: http://www.ozoneasylum.com/Forum12/HTML/000260.html

BTW Generally, this works only in IE (it can also be implemented in Mozilla, but it is very complicated)...

Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 07-31-2001 20:06

Mr. Max, how come you're so smart?

So you're after my second born as well as the first!


IE only isn't a problem for me, as my CMS is designed for IE anyways.

"It takes months to find a customer, more than 5 seconds of load time to lose one."

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 07-31-2001 20:47

Heh, I have another question for mr max: how come you're so smart, and yet your page has *no* dhtml on it whatsoever! Not that I can find, at least. Where on earth do you practice?? I'd never be able to remember what I do if I didn't use it all the time on my own page.

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 07-31-2001 21:50

Pugzly, I was born smart, he he heeee...

Slime, I have one DHTML script that I wrote on my web site (go to "About mr.maX" page and you'll see it in action), and another DHTML scroller script, but I didn't write it (I tweaked it, though). I also wrote some DHTML scripts on other sites that I made. Besides that, most of the scripts & code snippets that I wrote for people here at the Asylum are stored in my "Toxic Waste" folder as a reference for the future. I may even publish all that stuff on my new web site that is almost finished (it's completely rewritten using PHP and now that I mentioned PHP, I also have a lot of material about that language). And list goes on and on and on... Oh, and one more thing - I have a very good memory, he he heeee...

Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 07-31-2001 22:46

I gotta get smart.

Anyways, I used that example to add some basic functionality to my content management system, which is PHP/MySQL based. Very cool stuff!

The one thing I like about the example I posted is that if you don't have any text highlighted, and you, say, click on the BOLD button, it inserts the opening <b>. If you click it again, it inserts the closing </b>. That's in addition to handling highlighted text. But that code is pretty complex, and I get lost easy.

"It takes months to find a customer, more than 5 seconds of load time to lose one."

« BackwardsOnwards »

Show Forum Drop Down Menu