Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

add to drop down client-side

Status
Not open for further replies.

karenmierkalns

Programmer
May 10, 2001
54
CA
I am trying to add new options to a combo box, but the add method is not doing me any good. How do you use the add method for the combo boxes, and is it the right way to add?

For example, in the HTML code, I simply have:

<select name=&quot;cboCustomers size=5>
</select>

because based on what value they choose from another combo box (in its click event), I am triggering this combo box to add new values..this is possible client-side, isn't it? I don't want to have to use asp for this because I don't want to refresh the page.

In a vbscript sub, I have:

do while not rsCustomers.EOF
document.frmCompany.cboCustomers.add
rsCustomers.MoveNext
loop

I don't know how to use this add method...no matter how I use it, it doesn't seem to like it.

I saw some examples of using the options property, but I am not sure about that. Any help would be appreciated.

Thanks. - Karen
 
You have to tell it what to add in parenthesis C:\DOS:>
C:\DOS:>RUN
RUN DOS RUN!!
 
I realize that..but using InterDev, the only help it gives me is:

.add (element, [before])

However, whatever I enter in the place of element, it always says type mismatch..any help, please? - Karen
 
I've solved my own problem..I thought I'd post it in case someone in the future is looking for it.


-----

dim newElement

' clear combo box
do until document.frmCompany.cboCustomers.innerText = &quot;&quot;
document.frmCompany.cboCustomers.remove 0
loop

' populate combobox with company names
do while not rsCustomers.EOF
set newElement = document.createElement (&quot;OPTION&quot;)

' set value and text properties
newElement.value = rsCustomers.Fields(&quot;CustID&quot;)
newElement.text = rsCustomers.Fields(&quot;Name&quot;)

' actually add the element
document.frmCompany.cboCustomers.add (newElement)
rsCustomers.MoveNext
loop

- Karen
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top