I found this on the web somewhere, its very simple, clicking the button adds the tags to the textbox, and works perfectly.. except in firefox after clicking the button the textbox snaps (or scrolls) to the top (instead of the textbox staying right where it was pre-click) which is very annoying when dealing with large amounts of information,
<script>
function formatText(el,tagstart,tagend) {
if (el.setSelectionRange) {
el.value = el.value.substring(0,el.selectionStart) + tagstart + el.value.substring(el.selectionStart,el.selectionEnd) + tagend + el.value.substring(el.selectionEnd,el.value.length)
}
}
</script>
<textarea id='text_box'></textarea>
<input type='button' value='B' onclick="formatText(document.getElementById('text_box'),'<strong>','</strong>')"/>
I know nothing about javascript so any help would be amazing,
thanks in advanced,