Dynamically altering value of a textbox
Using Rails, I am building a new wiki system from scratch; however, I am unsure how to handle the buttons for the "create a page" se开发者_Python百科ction. Where, for example, a person were to press the "bold" button, it would dynamically add to the textbox below.
In theory, It should be a matter of using javascript to, "on click", add to the value of the textbox. I just do not know how to do this.
Please keep in mind that I am using ruby on rails, and I am not well versed in Javascript.
For your usage, I would recommend using something like TinyMCE, since it's a full-fledged javascript text editor that can be easily added to existing forms.
Generally, to append a text you just do somethig like:
document.getElementById('textbox').value += "something";
Transforming is done by getting .value and changing it to your likes.
精彩评论