Reputation: 1063
I am going to design a textarea for writing some formula. Since typing entire formula may cause mistake in formula, I think its is better that users drag and drop variables from another panel. I believe that stackoverflow's tag option could be usefull for this purpose.
How it is possible to design a text area like this?
Upvotes: 2
Views: 11760
Reputation: 317
You cannot directly convert the text box into tag. But you can make it look like a text box by giving a container to have the tag inside and a text box.
<div id="container"><span id="tagContainer"></span>
<input type="text" id="inputText" placeholder="input here.." />
</div>
Using keypress
event, you can grab the value of textbox and append it into tagContainer
. You can see the implementation here: JSFiddle
Upvotes: 4
Reputation: 486
This plugin might be helpful for you. http://aehlke.github.io/tag-it/
Upvotes: 0
Reputation: 2526
You can't.
However you can put another text block with highlight content at same position with that textarea or input.
Reference:
Visit https://codepen.io/lonekorean/pen/gaLEMR
Upvotes: 0