Forum Moderators: open
function addtoelement(myValue,elem)
{myField=documetn.getElementById(elem);
if (document.selection) {
myField.focus();
sel = document.selection.createRange();
sel.text = myValue;
}
else if (myField.selectionStart ¦¦ myField.selectionStart == '0')
{
startPos = myField.selectionStart;
endPos = myField.selectionEnd;
myField.value = myField.value.substring(0, startPos)+ myValue+ myField.value.substring(endPos, myField.value.length);
myField.selectionStart=startPos+Math.round((myValue.length-1)/2);
myField.selectionEnd=startPos+Math.round((myValue.length-1)/2);
myField.focus();
} else {
myField.value += myValue;
}
}
in a body u should have
<textarea id="insert" ></textarea>
<img src='somesource' onclick=addtoelement('','insert') />
not a problem to modify this code to you situation