Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Apr 2003
    Location
    Seoul, Korea
    Posts
    329
    Thanks
    0
    Thanked 0 Times in 0 Posts

    <b></b> are always created at the end of the message

    Code:
    <script type="text/javascript">
       function appendValue(str)
      {
      document.forms[0]['t'].value += str;
      }	
    </script>
    
    <form action="form_action.php">
    	
    <input type="button" value=" b " onclick="appendValue('<b>');">
    <input type="button" value=" /b " onclick="appendValue('</b>');">
    <textarea name="message" id="t" cols="76" rows="20"></textarea>
    <input type="submit" value="Submit">
    </form>
    The above javascript work fine
    when a user enters his messages, he can click the <b> or </b>button instead of entering it.

    But I found one modification is needed.

    Let's suppose the message is "My name is <b>John</b>".

    The user can enter;
    "My name is [click <b> button] John [ click</b> button] ."

    So far it's Okay.

    But some users do the following.

    He enter " My name is John." and put his mouth in front of the word "John". and click the <b> button.

    And put his mouse between John and the period(.) and click the
    </b> button.


    In this case, the above code doesn't work correctly.

    Although the user put his mouse in front of the word "John", the <b> is created at the end of the message.( not in front of the word "John")


    I hope you understand what I am talking about and help me.

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rather than let you re-invent the wheel, try looking at this code from Dave Clark (who used to be a regular here).

    http://www.daveclarkconsulting.com/r...cted_text.html
    Check out the Forum Search. It's the short path to getting great results from this forum.

  • #3
    Regular Coder
    Join Date
    Apr 2003
    Location
    Seoul, Korea
    Posts
    329
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have to say, I am afraid, The link you suggested is not helful.

    I can't see its result and source.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •