This won't be too helpful as I'm not expert with javascript, but basically.... here's an example:
Code:
<input type="checkbox" onClick="if (this.value != checked) {textarea.value = 'this is some code'} else {textarea.value = ''}">
<textarea id="textarea"></textarea>
<br><br><br>
<input type="checkbox" onClick="if (this.value != checked) {textbox.value = 'this is some code'} else {textbox.value = ''}">
<input type="text" id="textbox">
Now, it obviously gets more complex if you want it to do something like add code to the middle of what's already there, or change what's already there in some other way, etc. It's possible, just more work. If you get more complex than what's above, I'd recommend making a function and referring to it from the input checkbox...
<input type="checkbox" onClick="dostuff()">
(and define dostuff() as a function in the head section, between <script> tags)
Also, I'll note that I was a bit confused when writing this because I needed to use the id attribute on the fields, rather than name. Not sure why this is. (I'm using safari, so maybe that's part of it).
Note: It's "!= checked" because when you're clicking, it's the opposite of what it changes to, so the text should match the opposite of what you clicked.
Bookmarks