473,327 Members | 2,081 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

adding large number of options to combo box

Ranjan kumar Barik
Hi!

I want to create a combo box that will contain too many data like name of all
the countries.

Is there any other method I can use to do that without adding all of them using
the <option> tag all time.

!!!! LIKE can I use loop for this

PLEASE HELP ME !!!!!!!

Thanks
Aug 27 '07 #1
7 1626
I'm not sure what you are looking for out of a loop, but if you have all of the countries listed in a table already, you can use a SELECT statement on the rowsource of your combo box.

Hope this helps,
Tiffany
Aug 27 '07 #2
I'm not sure what you are looking for out of a loop, but if you have all of the countries listed in a table already, you can use a SELECT statement on the rowsource of your combo box.

Hope this helps,
Tiffany
Hello tcveltma !!

Thanks for ur reply.You are the 1st to reply me.And I am very sorry that I have asked hapazardly.

Actual thing is I have tried this by storing a few the country names in an array and calling them like this (it's in vbscript);
Expand|Select|Wrap|Line Numbers
  1. <%
  2. dim country(10)
  3. country(0)=india
  4. . . . . ..
  5. . . . . . .
  6. response.wite("<select>")
  7. for i=0 to 10
  8. response.write("<option>" & country( i ) )
  9. respose.write("</option>")
  10. next
  11. response.write("</select>")
  12. %>
  13.  
but this is a tedious prossess and better to write all the <options> one after another.Simply I want to do it without using tables.I actually have been assigned with this task and I donot find any other way.

Thanks again !!!!!
Aug 28 '07 #3
markrawlingson
346 Expert 100+
I wrote a nice little script that handles this.

Below is the code...
Expand|Select|Wrap|Line Numbers
  1. Function CreateCountries
  2.      Set oFileStream = Server.CreateObject("Scripting.FileSystemObject")
  3.      Set oCountries = oFileStream.OpenTextFile(Server.MapPath("/platform/Countries.txt"), 1)
  4.      aCountries = Split( oCountries.ReadAll, vbCRLF )
  5.      oCountries.Close
  6.      Set oCountryOptions = oFileStream.OpenTextFile(Server.MapPath("/platform/CountryOptions.txt"), 1)
  7.      aCountryOptions = Split( oCountryOptions.ReadAll, vbCRLF )
  8.      sTemp = sTemp & "<select name=" & Chr( 34 ) & "sCountry" & Chr( 34 ) & " id=" & Chr( 34 ) & "sCountry" & Chr( 34 ) & " style=" & Chr( 34 ) & "width:270;" & Chr( 34 ) & ">"
  9.      sTemp = sTemp & "<option value=" & Chr( 34 ) & Chr( 34 ) & "></option>"
  10.      For i = 0 to Ubound(aCountries)
  11.           sTemp = sTemp & "<option value=" & Chr( 34 ) & aCountryOptions(i) & Chr( 34 ) & ">" & aCountries(i) & "</option>"
  12.      Next
  13.      Set oCountries = Nothing
  14.      Set oCountryOptions = Nothing
  15.      Set oFileStream = Nothing
  16.      CreateCountries = sTemp
  17. End Function
  18.  
Now, of course, You'll have to have a couple of .txt documents located on the server. One to define the option values, and another to define the textual output of each option.

I have these files if you'd like, but i won't put them here.. they're about 300 lines each.

Email me and i'll give them to you.

To invoke this, include it in some way, shape, or form on your page - and simply...

Call CreateCountries

I also created one for all the Canadian provinces and US states.
Aug 28 '07 #4
I wrote a nice little script that handles this.

Below is the code...
Expand|Select|Wrap|Line Numbers
  1. Function CreateCountries
  2.      Set oFileStream = Server.CreateObject("Scripting.FileSystemObject")
  3.      Set oCountries = oFileStream.OpenTextFile(Server.MapPath("/platform/Countries.txt"), 1)
  4.      aCountries = Split( oCountries.ReadAll, vbCRLF )
  5.      oCountries.Close
  6.      Set oCountryOptions = oFileStream.OpenTextFile(Server.MapPath("/platform/CountryOptions.txt"), 1)
  7.      aCountryOptions = Split( oCountryOptions.ReadAll, vbCRLF )
  8.      sTemp = sTemp & "<select name=" & Chr( 34 ) & "sCountry" & Chr( 34 ) & " id=" & Chr( 34 ) & "sCountry" & Chr( 34 ) & " style=" & Chr( 34 ) & "width:270;" & Chr( 34 ) & ">"
  9.      sTemp = sTemp & "<option value=" & Chr( 34 ) & Chr( 34 ) & "></option>"
  10.      For i = 0 to Ubound(aCountries)
  11.           sTemp = sTemp & "<option value=" & Chr( 34 ) & aCountryOptions(i) & Chr( 34 ) & ">" & aCountries(i) & "</option>"
  12.      Next
  13.      Set oCountries = Nothing
  14.      Set oCountryOptions = Nothing
  15.      Set oFileStream = Nothing
  16.      CreateCountries = sTemp
  17. End Function
  18.  
Now, of course, You'll have to have a couple of .txt documents located on the server. One to define the option values, and another to define the textual output of each option.

I have these files if you'd like, but i won't put them here.. they're about 300 lines each.

Email me and i'll give them to you.

To invoke this, include it in some way, shape, or form on your page - and simply...

Call CreateCountries

I also created one for all the Canadian provinces and US states.

Hello markrawlingson !!!
Thank you for helping me.
I will be obliged if you please send me those files.

Thanks in advance !!!!
Aug 29 '07 #5
markrawlingson
346 Expert 100+
Certainly. Provide me over PM with your email address and I will send you 4 files.

Countries.txt
CountryOptions.Txt
Provinces.txt
ProvinceOptions.txt

They latter 2 will probably come in handy at some point or another.

And you will of course have to modify the function above to correct the file location for where ever you put these in your directory structure.

Sincerely,
Mark
Aug 29 '07 #6
Certainly. Provide me over PM with your email address and I will send you 4 files.

Countries.txt
CountryOptions.Txt
Provinces.txt
ProvinceOptions.txt

They latter 2 will probably come in handy at some point or another.

And you will of course have to modify the function above to correct the file location for where ever you put these in your directory structure.

Sincerely,
Mark
THanks Mark !!!!!!!
I got all files.
Aug 31 '07 #7
markrawlingson
346 Expert 100+
No problem, hope they come in handy for you :)
Aug 31 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: vb | last post by:
Hi, I am new to .Net. I am using a Combo Box in my windows forms. I am adding the items by creating the instances and adding the same to the list. My questions/doubts are: 1. If I have 25 to...
0
by: vb | last post by:
Hi, I am new to .Net. I am using a Combo Box in my windows forms. I am adding the items by creating the instances and adding the same to the list. My questions/doubts are: 1. If I have 25 to...
5
by: consonanza | last post by:
I am working on a report filter form. It has 2 combo boxes (cmboSelectSubject and cmboSelectCategory) to select criteria. Selecting an entry in combo 1 restricts the options available in combo 2....
1
Ranjan kumar Barik
by: Ranjan kumar Barik | last post by:
Hi! I want to put a combo box that will contain large number of options like the name of all the coutries. Is ther any other way I can do that without entering all the options using <option>...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.