View Full Version : <b></b> are always created at the end of the message

12-22-2003, 07:40 AM
<script type="text/javascript">
function appendValue(str)
document.forms[0]['t'].value += str;

<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">

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.

Roy Sinclair
12-22-2003, 10:57 PM
Rather than let you re-invent the wheel, try looking at this code from Dave Clark (who used to be a regular here).


12-23-2003, 12:31 AM
I have to say, I am afraid, The link you suggested is not helful.

I can't see its result and source.