开发者

Dynamically altering value of a textbox

开发者 https://www.devze.com 2023-04-13 07:37 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号