1

I have a textarea in a html form and I would like to have a button to add a big black dot character (•) (is this called a bullet?) into this textarea. is it possible in javascript?

Also it needs to be a UTF8 character.

Thanks for your help!

1

2 Answers 2

5

Just access the element and append it to the value.

<input
     type="button" 
     onclick="document.getElementById('myTextArea').value += '•'" 
     value="Add •">

See a live demo.

For the sake of keeping things simple, I haven't written unobtrusive JS. For a production system you should.

Also it needs to be a UTF8 character.

Browsers generally submit forms using the encoding they received the page in. Serve your page as UTF-8 if you want UTF-8 data submitted back.

2
  • @David — The innerHTML property will set the default value, value will set the current value. It is the current value that we care about. Don't confuse the value property with the attribute of the same name.
    – Quentin
    Aug 28, 2012 at 12:49
  • Note the DOM spec for textareas which defines the value property: Represents the current contents of the corresponding form control, in an interactive user agent. Changing this attribute changes the contents of the form control
    – Quentin
    Aug 28, 2012 at 12:52
5

you can use html entity as &bull;

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.