Select assistance - Magic-Mouse.Net


Code
<html>
<head>
<title>javaScriptTest</title>

<script>

function insertAtCursor(myField, myValue_i) {
  // Source of this function.
  // http://alexking.org/blog/2003/06/02/inserting-at-the-cursor-using-javascript
  //IE support

  myValue = myValue_i.value;
  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 + '3';

  }
myValue_i.value = '#';
}
</script>
</head>
<body>


<select size=1 onchange="insertAtCursor(document.getElementById('text_felt'), this)">
<option value="#" class="tekst">&nbsp;dk&nbsp;</option>    
<option value="æ" class="u">&nbsp;[æ]&nbsp;</option>
<option value="Æ" class="u">&nbsp;[Æ]&nbsp;</option>
<option value="ø" class="u">&nbsp;[ø]&nbsp;</option>
<option value="Ø" class="u">&nbsp;[Ø]&nbsp;</option>
<option value="å" class="u">&nbsp;[å]&nbsp;</option>
<option value="Å" class="u">&nbsp;[Å]&nbsp;</option>
<option value="©" class="u">&nbsp;[©]&nbsp;</option>
<option value="®" class="u">&nbsp;[®]&nbsp;</option>    
<option value="ª" class="u">&nbsp;[ª]&nbsp;</option>
<option value="&Psi;" class="u">&nbsp;[&Psi;]&nbsp;</option>
<option value="&nbsp;" class="u">space</option>
</select> 
<hr>
<textarea class="textarea" cols="50" rows="6" name="text_felt" id="text_felt">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla ligula risus, semper quis rhoncus vitae, dapibus sed lorem.
</textarea>
</body>
</html>
Content is copyright www.magic-mouse.net | System is copyright Magic-Mouse.Net | Design By Snorri Debess