, Enter:
JavaScript
<script type="text/javascript">
var LastKeyCode=-1;
function updateOptions(e) {
if (e.keyCode) {
var KeyCode=e.keyCode;
} else {
var KeyCode=e.charCode;
}
if (KeyCode==13 && LastKeyCode==13) {
var RowsDataAry=document.getElementById('inputfield').value.replace(/\r\n/g,"\n").split(/\n{2,}/g);
document.getElementById('choices').options.length=0;
for (RowID in RowsDataAry) {
var TextVal=RowsDataAry[RowID].replace(/\n/g,", ").replace(/, $/,"");
document.getElementById('choices').options.length++;
document.getElementById('choices').options[RowID].value=RowID;
document.getElementById('choices').options[RowID].text=TextVal;
;
}
}
LastKeyCode=KeyCode;
}
</script>
HTML
<select id="choices" size="20"></select>
<textarea id="inputfield" onkeypress="updateOptions(event)" cols="40" rows="20"></textarea>
Firefox 3.6.3, Opera 10.53, IE 8 Iron 5.0.380.