S
shankwheat
I'm trying to add an option to a select box dynamically. A typical
string value is delimitted by a # character. There will always be
only one option to add. What's happening is that the option text value
shows up twice in the selectbox.
I'm getting this:
<select id="ddlSavedBenchmarks">
<option>mytext</option>
<option>28</option>
</select>
Instead of this:
<select id="ddlSavedBenchmarks">
<option value="28">mytext</option>
</select>
results = "mytext#28"
// Split the delimited response into an array
results = xmlHttp.responseText.split("#");
for (var i=0; i < results.length;++i){
addOption(document.choiceForm.ddlSavedBenchmarks, results,
results);
}
function addOption(selectbox,text,value )
{
var optn = document.createElement("OPTION");
optn.text = text;
optn.value = value;
selectbox.options.add(optn);
}
Thanks
string value is delimitted by a # character. There will always be
only one option to add. What's happening is that the option text value
shows up twice in the selectbox.
I'm getting this:
<select id="ddlSavedBenchmarks">
<option>mytext</option>
<option>28</option>
</select>
Instead of this:
<select id="ddlSavedBenchmarks">
<option value="28">mytext</option>
</select>
results = "mytext#28"
// Split the delimited response into an array
results = xmlHttp.responseText.split("#");
for (var i=0; i < results.length;++i){
addOption(document.choiceForm.ddlSavedBenchmarks, results,
results);
}
function addOption(selectbox,text,value )
{
var optn = document.createElement("OPTION");
optn.text = text;
optn.value = value;
selectbox.options.add(optn);
}
Thanks