By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,605 Members | 2,129 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,605 IT Pros & Developers. It's quick & easy.

activeComboBox

P: n/a
Hello, I have to activate a combo box in a html form to load an array of
values within the combo. Is there an example somewhere?

TIA
Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
carlo wrote:
Hello, I have to activate a combo box in a html form to load an array of
values within the combo. Is there an example somewhere?


There are no combo boxes in HTML. You mean a `select' element of size 1
which is displayed as a dropdown box in graphical user agents. You can
focus any form element with its focus() method. Besides, there are
plenty of postings in the newsgroup that describe how to add options to
a `select' element (as a Select or HTMLSelectElement object) and how to
remove them.
HTH

PointedEars
Jul 20 '05 #2

P: n/a
Hi Carlo

Don't you think of a <SELECT>-element?

Here's an example:

SELECT-element:
<SELECT ID="idSelect" SIZE="1" onChange="dostuff(this.value);"></SELECT>

Adding options:
function addOptions() {
var numberOfNewOptions = 10;
var getSelect = document.getElementById("idSelect");
for (var i = 0; i < numberOfNewOptions; i++) {
var option = new Option("This is option number " + i,i);
getSelect.options[getSelect.length] = option;
}
}

Removing options:
function removeOptions() {
var getSelect = document.getElementById("idSelect");
while (getSelect.options.length) {
getSelect.options[0] = null;
}
}

Best regards,

Jeppe Andersen
Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.