-
Dynamically adding to a Select box
I use this code to dynamically add <options> to a select box. In IE it works
fine, but I don't think it is supported in NS6. Anyone know of a way to do
this in Netscape 6.1?
var eNewItem = document.createElement("<OPTION value='" +sValue +"'>");
eNewItem.text = sText;
document.getElementById("text").add(eNewItem);
Any help here would be great!
-
Re: Dynamically adding to a Select box
"Aaron Chorpenning" <terak@lords.com> wrote:
>
>I use this code to dynamically add <options> to a select box. In IE it works
>fine, but I don't think it is supported in NS6. Anyone know of a way to
do
>this in Netscape 6.1?
>
>var eNewItem = document.createElement("<OPTION value='" +sValue +"'>");
>eNewItem.text = sText;
>document.getElementById("text").add(eNewItem);
>
>Any help here would be great!
yes I just recently had to dynamically add some countries to an option list.
check out the option object. I'd make the hieght > 1 of the options once
you add more options, otherwise you get this ugly little scroll box
my code had an array of objects, in which i assigned the property of that
'ith' object in the loop to a new option object and thus adding it to the
end of the current option list i had.
for (i=0; i<arrObj.length; i++)
{var newOpt = document.forms.f1.CountrySelection.options;
newOpt[i] = new Option(arrObj[i].countryName);
newOpt.text=arrObj[i].countryName;
newOpt.value=arrObj[i].countryName;
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks