#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2002
    Location
    la
    Posts
    56
    Rep Power
    13

    javascript + textarea + select??


    ok- so Im building an html generator with javascript... basically there is a <textarea> input field where the html text that is to be displayed on the generated page is typed in by the user.

    what I want to be able to do is insert html tags around text that the user highlights.

    for example, i will have a "bold" button. If the user types the sentence "This word should be bold." and then highlights the word "This" and clicks the bold button, the javaScript will insert the <b> before the highlighted word and the </b> tag after the highlighted word.

    is it possible??

    thanks in advance

    -stank
  2. #2
  3. No Profile Picture
    rubbish in javascript
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2001
    Location
    London
    Posts
    706
    Rep Power
    14
    hello

    i hope someone can correct me but i dont think its possible, have a look at the insert "http" "@" etc buttons used here in devshed just above this window and the javascript used in them at

    http://forums.devshed.com/vbcode.js

    and they'll give you an idea of what is possible, notice thing like if you write a text and they go back to insert a url at the begining of your text it will insert the url at the end, so it cant detect where you have clicked in the <textarea>. <textarea> is not sensitive to mouse interaction, clicks and highlights and i think you would have to use a select as follows to get that sort of interaction

    <select name="select" size="5" multiple>
    <option>1</option>
    <option>2</option>
    <option>2</option>
    <option>2</option>
    </select>

    of course then selects are not editable so thats no help!

    sorry!

    a+
    gar
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2001
    Location
    Montana
    Posts
    504
    Rep Power
    14
    I wish the people who make the browsers would incorporate a text edit feature in the browser itself!
    Have Eternal Life
    Learning is so unproductive...
    The more I learn the more questions I have!
    Therefore I am going backwards.
  6. #4
  7. No Profile Picture
    rubbish in javascript
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2001
    Location
    London
    Posts
    706
    Rep Power
    14
    well does'nt netscape have "composer"?? don't know how good/bad it is, never used it!

    anyway if you want to edit your html in the browser you should check out "manilla" one server i can recommend that has manilla sites is...

    http://www.myprotova.com/

    a+
    gar
    Last edited by Garrett_44; April 12th, 2002 at 03:51 PM.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2001
    Posts
    765
    Rep Power
    13
    Both Internet Explorer and Netscape 6/mozilla provide complete functionality to accomplish what you are trying to do. Even Netscape 4 can come close (plenty of workarounds, though). There is no shortage of 'features' in the newer browsers, just a lack of standardization in terms of the interface. Here's a few useful links:

    http://msdn.microsoft.com/workshop/a...asp?frame=true

    http://www.webreference.com/js/column12/index.html

    http://www.faqts.com/knowledge_base/...d/1052/fid/130

    http://www.siteexperts.com/ie5/htmlarea/page1.asp

    http://www.pbwizard.com/Articles/Moz...ct_Article.htm
    Last edited by mrrichardfeder; April 13th, 2002 at 03:24 PM.
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2002
    Location
    la
    Posts
    56
    Rep Power
    13
    cool... thanks for all the help guys...

    im gonna try and get this thing workin!


IMN logo majestic logo threadwatch logo seochat tools logo