<html>
<body>
<form name="Mainform">
<textarea name="dataentry" rows="5" cols="45">
</textarea>
<input Type="Button" Name="loadbutton" Value="LOAD" onclick="BuildSelect()"><BR><BR>
<select name="dataadded" multiple>
</select>
</form><BR><BR>
<script Language="Javascript">
function BuildSelect(){
var Options = document.forms[0].dataadded.options;
var startIndex = Options.length;
var sourceString = document.forms[0].dataentry.value;
sourceString = sourceString.replace(/\s*(.*),([^,\n]*);/g, '"$1" <$2>,##splitstringhere##');
var thearray = sourceString.split('##splitstringhere##');
for (var i=0; i < thearray.length; i++) {
if (thearray[i].match(/\S/)) {
Options[i+startIndex] = new Option(thearray[i],thearray[i]);
}
}
}
</script>
</body>
</html>
|