Webmaster Forum


Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Coding Forum Problems with your code? Let's hear about it.

Sponsored Reviews   High Bandwidth Dedicated Servers   V7N Directory

Reply
 
LinkBack Thread Tools Display Modes
Old 09-09-2004, 03:12 AM   #1 (permalink)
Contributing Member
 
DragonEye's Avatar
 
Join Date: 10-13-03
Location: Belgium
Posts: 316
iTrader: 0 / 0%
Latest Blog:
None

DragonEye is liked by somebodyDragonEye is liked by somebodyDragonEye is liked by somebodyDragonEye is liked by somebodyDragonEye is liked by somebody
Send a message via MSN to DragonEye
JavaScript help needed

hi,

What I'm trying to do is the following:
I want a form with a text area with three buttons next to it.

Those buttons are: bold, underline, italic

When a user selects text in the textarea and then clicks 'Bold' a javascript should make appear at the beginning and the end of the selected text.

I have searched for methods to do this but I can't get it to work

plz help

thanks

DragonEye
DragonEye is offline  
Add Post to del.icio.us
Reply With Quote
Sponsored Links
SEO Hosting by HostGator  Advertise Here  Buy Blog Links
Old 09-09-2004, 03:27 AM   #2 (permalink)
Moderator
 
LazyJim's Avatar
 
Join Date: 10-13-03
Location: UK
Posts: 2,819
iTrader: 0 / 0%
Latest Blog:
None

LazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to all
Send a message via MSN to LazyJim
google getselection()
that should give you lot's of info on the JavaScript feature you'll probably want to use.
__________________

-LJ-

My advice is to look at each case individually, with an informed mind and an appropriately balanced and objective viewpoint.

Web Design and Development, Ipswich, UK.
My deviantArt
LazyJim is offline  
Add Post to del.icio.us
Reply With Quote
Old 09-10-2004, 05:34 AM   #3 (permalink)
Contributing Member
 
DragonEye's Avatar
 
Join Date: 10-13-03
Location: Belgium
Posts: 316
iTrader: 0 / 0%
Latest Blog:
None

DragonEye is liked by somebodyDragonEye is liked by somebodyDragonEye is liked by somebodyDragonEye is liked by somebodyDragonEye is liked by somebody
Send a message via MSN to DragonEye
no,

getseletion only works in netscape navigator.
I have found some sort of solution, but it's far from perfect

But there are several problems:
  • If the selected part is in the textarea field more than once, the first occurence is taken
  • Only works on Internet Explorer as the commands for determining the selected part are different in netscape, i have noticed that this forum's post form uses the same system and works on both internet explorer and netscape. Must be some fine coding

Code:
if(navigator.userAgent.indexOf("MSIE")==-1) { alert("Deze functie werkt enkel met Microsoft Internet Explorer"); } else if(navigator.userAgent.indexOf("MSIE")!==-1) { var selectie = document.selection.createRange().text; } var alletekst = document.getElementById(veld).createTextRange().text; var selectielengte = document.selection.createRange().text.length; var beginposselectie = alletekst.indexOf(selectie); document.getElementById(veld).value = alletekst.substring(0,beginposselectie) + "["+tag+"]" + selectie + "[/"+tag+"]" + alletekst.substring((beginposselectie+selectielengte),alletekst.length);
DragonEye is offline  
Add Post to del.icio.us
Reply With Quote
Old 09-10-2004, 07:05 AM   #4 (permalink)
Moderator
 
LazyJim's Avatar
 
Join Date: 10-13-03
Location: UK
Posts: 2,819
iTrader: 0 / 0%
Latest Blog:
None

LazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to all
Send a message via MSN to LazyJim
use the TextRange obkect in MSIE search for that on MSDN web site

Yes there are differences, that's why when I needed it I chose to only support IE. Might do a x-browser solution in the future though.
__________________

-LJ-

My advice is to look at each case individually, with an informed mind and an appropriately balanced and objective viewpoint.

Web Design and Development, Ipswich, UK.
My deviantArt
LazyJim is offline  
Add Post to del.icio.us
Reply With Quote
Old 09-12-2004, 11:46 PM   #5 (permalink)
Contributing Member
 
DragonEye's Avatar
 
Join Date: 10-13-03
Location: Belgium
Posts: 316
iTrader: 0 / 0%
Latest Blog:
None

DragonEye is liked by somebodyDragonEye is liked by somebodyDragonEye is liked by somebodyDragonEye is liked by somebodyDragonEye is liked by somebody
Send a message via MSN to DragonEye
Smile

this is the solution to my problem.

Code:
function opmaak(tag,veld) { var geselecteerd = document.selection.createRange().text; var nieuwetekst = "["+tag+"]"+geselecteerd+"[/"+tag+"]"; document.selection.createRange().text = nieuwetekst; }
DragonEye is offline  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum

Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Javascript help please!!! searchbliss Coding Forum 10 01-18-2008 03:39 AM
javascript help mtaylor314 Coding Forum 2 05-04-2007 03:46 PM
Count-up from a particular year + Javascript within Javascript? Help! Azam.biz Coding Forum 3 06-06-2005 06:47 AM
I need some help with JavaScript. Can anyone help me please? CrAg Coding Forum 2 03-22-2004 05:56 AM


Sponsor Links
Get exposure! Get exposure! Find Scripts Web Hosting Directory Get exposure! SEO Blog


All times are GMT -7. The time now is 07:20 AM.
© Copyright 2008 V7 Inc