42DoubleDDs
IS-IT--Management
´*•.¸(`*•.¸?¸.•*´)¸.•*´
?«´•°*42DoubleDDs*°•´»?
.¸.•*(¸.•*´?`*•.¸) *•.¸
How can I dynamically populate two comboboxes with the Values of a textarea?
Script below will dynamically populate a single combobox, one entry at a time, from an input box.
Would like to:
-dynamically build textarea
-dynamically build, populate comboboxes
-split between punctuation ( and sort Comboboxes by name (acs)
Thank You........@}-,-`-
RESULTS WOULD LOOK LIKE THIS:
Textarea:
________________________________
Mr. Smith;JSmith@hotmail.com;
Ms. Jones;TJones@hushmail.com;
Mr. White;AWhite@Yahoomail.com;
________________________________
Combobox1
________________________________
Mr. Smith
Mr. White
Ms. Jones
________________________________
Combobox2
________________________________
JSmith@hotmail.com
AWhite@Yahoomail.com
TJones@hushmail.com
________________________________
Code:
<HTML>
<HEAD>
<TITLE>Dynamically populating drop down, combobox, list box using JavaScript</TITLE>
<SCRIPT language="javascript">
function addCombo() {
var textb = document.getElementById("txtCombo");
var combo = document.getElementById("combo");
var option = document.createElement("option");
option.text = textb.value;
option.value = textb.value;
try {
combo.add(option, null); //Standard
}catch(error) {
combo.add(option); // IE only
}
textb.value = "";
}
</SCRIPT>
</HEAD>
<BODY style="font-family: sans-serif">
<fieldset>
<legend>Combo box</legend>
Add to Combo: <input type="text" name="txtCombo" id="txtCombo"/>
<input type="button" value="Add" onclick="addCombo()">
<br/>
Combobox: <select name="combo" id="combo"></select>
</fieldset>
</BODY>
</HTML>