Parašė sampas· 2008 Kov. 19 18:03:58
#4
Jeigu gerai supratau, tai dariau štai taip:
<tr>\n<td class='tbl'></td>\n<td class='tbl'>
<script>
function insertText(elname, what) {
if (document.forms['inputform'].elements[elname].createTextRange) {
document.forms['inputform'].elements[elname].focus();
document.selection.createRange().duplicate().text = what;
} else if ((typeof document.forms['inputform'].elements[elname].selectionStart) != 'undefined') { // for Mozilla
var tarea = document.forms['inputform'].elements[elname];
var selEnd = tarea.selectionEnd;
var txtLen = tarea.value.length;
var txtbefore = tarea.value.substring(0,selEnd);
var txtafter = tarea.value.substring(selEnd, txtLen);
var oldScrollTop = tarea.scrollTop;
tarea.value = txtbefore + what + txtafter;
tarea.selectionStart = txtbefore.length + what.length;
tarea.selectionEnd = txtbefore.length + what.length;
tarea.scrollTop = oldScrollTop;
tarea.focus();
} else {
document.forms['inputform'].elements[elname].value += what;
document.forms['inputform'].elements[elname].focus();
}
}
</script>
<input type='button' value='lentele' class='button' style='width:45px' onClick=\"insertText('body', '<table class=\'lentele\'><tr><td></td><td></td></tr><tr><td></td><td></td></tr></table>');\">
</td>
</tr>\n";
, tačiau taip padarius nesigavo. Gal ką ne taip darau?