DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Select Box Additions

Hybrid View

  1. #1
    Mark Taylor Guest

    Select Box Additions


    Hi there, I know how to load a select box up with server side scripting.
    Was wondering if it is possible to use javascript and add items to a select
    box once the page is displayed at the client browser. Tried using the add
    function but keep getting type mismatch.

  2. #2
    Glenn Guest

    Re: Select Box Additions


    "Mark Taylor" <mtaylor1@cbsinc.com> wrote:
    >
    >Hi there, I know how to load a select box up with server side scripting.


    >Was wondering if it is possible to use javascript and add items to a select
    >box once the page is displayed at the client browser. Tried using the add
    >function but keep getting type mismatch.

    Mark,

    This is to answer part two of your question. I have a better way to do this
    using the IE DOM, but I don't know if you have to support Netscape also,
    so I think this will work in both (sorry, but this is vbScript, shouldn't
    be too hard to convert though):

    'first bump up the length of the options array:
    myform.cboMyCombo.options.length = myform.cboMyCombo.options.length + 1

    'Now set value and text
    myform.cboMyCombo.Options(myform.cboMyCombo.Options.Length - 1).Value = "CA"

    myform.cboMyCombo.Options(myform.cboMyCombo.Options.Length - 1).Text = "California"


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center