Hallo, Achim,
ich möchte aus einer listenauswahl bestimmt werte an eine bestimmte stelle in einem textarea-bereich kopieren.
Ist das möglich?
Gibts dazu irgendwo ne Doku?
Besser noch ein beispiel?
Versuch's mal für das Einsetzen mit dem Code unten. Jetzt musst Du nur noch 'this value' mit dem Wert aus Deiner Listenauswahl ersetzen ....
Grüße,
Sebastian
Quelle: http://www.alexking.org/index.php?content=software/javascript/content.php
JavaScript to insert text at the current position of the cursor in a textarea. This is a genericized version of a function found in PHPMyAdmin.
function insertAtCursor(myField, myValue)
{
// IE support
if(document.selection) {
myField.focus();
sel = document.selection.createRange();
sel.text = myValue;
}
// MOZILLA/NETSCAPE support
else if(myField.selectionStart || myField.selectionStart == '0') {
var startPos = myField.selectionStart;
var endPos = myField.selectionEnd;
myField.value = myField.value.substring(0, startPos)
- myValue
- myField.value.substring(endPos, myField.value.length);
}
else {
myField.value += myValue;
}
}
// calling the function
insertAtCursor(document.formName.fieldName, 'this value');