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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to add item to the drop-down list (combo box)?

Status
Not open for further replies.

Phylis

Technical User
Oct 10, 2003
18
0
0
GB
I face problem in adding new item into the combo box. The problem is the item appear in separate combobox rather than in a single.

In visual basic, we could add item into combobox using the .additem. When I use this in ASP, the error is "object does not support....." What is the correct syntax for adding item into combobox in ASP?

 
I don't think there is any such method. You can put all items in an array, and then write out the HTML code for it:
Code:
<select name=&quot;mylist&quot;>
<% for x = 0 to UBound(arrItems)
     response.write &quot;<option value=&quot;&quot;&quot; & arrItems(x) & &quot;&quot;&quot;>&quot; & _
       arrItems(x) & &quot;</option>&quot;
   next %>
</select>

HTH

Choo Khor
choo.khor@intelebill.com
 
I use server side dtcs with visual interdev and this is the method that I use
Code:
sub addExample(lstAddedIn,strExample)
		
		dim lstBox
		dim zeroIndexValue
		
		Set lstBox=lstAddedIn
		zeroIndexValue=lstBox.getValue(0)
		
		'check if 0 index has 0 value
		if zeroIndexValue<>&quot;Ex&quot; then
			'add the example text in index 0
			lstBox.addItem strExample,&quot;Ex&quot;,0
		end if
		
	end sub

I don't know if this will work with other listboxes and dropdowns but it works like a charm with the dtcs
Crystal
crystalized_s@yahoo.com

--------------------------------------------------

Experience is one thing you can't get for nothing.

-Oscar Wilde

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top