adding large number of options to combo box

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ranjan kumar Barik
    New Member
    • Aug 2007
    • 95

    adding large number of options to combo box

    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
  • tcveltma
    New Member
    • Jul 2007
    • 36

    #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

    Comment

    • Ranjan kumar Barik
      New Member
      • Aug 2007
      • 95

      #3
      Originally posted by tcveltma
      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);
      [code=asp]
      <%
      dim country(10)
      country(0)=indi a
      . . . . ..
      . . . . . .
      response.wite(" <select>")
      for i=0 to 10
      response.write( "<option>" & country( i ) )
      respose.write(" </option>")
      next
      response.write( "</select>")
      %>
      [/code]
      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 !!!!!
      Last edited by jhardman; Aug 28 '07, 07:57 PM. Reason: put code in code tags. please use code tags in the future

      Comment

      • markrawlingson
        Recognized Expert Contributor
        • Aug 2007
        • 346

        #4
        I wrote a nice little script that handles this.

        Below is the code...
        [code=asp]
        Function CreateCountries
        Set oFileStream = Server.CreateOb ject("Scripting .FileSystemObje ct")
        Set oCountries = oFileStream.Ope nTextFile(Serve r.MapPath("/platform/Countries.txt") , 1)
        aCountries = Split( oCountries.Read All, vbCRLF )
        oCountries.Clos e
        Set oCountryOptions = oFileStream.Ope nTextFile(Serve r.MapPath("/platform/CountryOptions. txt"), 1)
        aCountryOptions = Split( oCountryOptions .ReadAll, vbCRLF )
        sTemp = sTemp & "<select name=" & Chr( 34 ) & "sCountry" & Chr( 34 ) & " id=" & Chr( 34 ) & "sCountry" & Chr( 34 ) & " style=" & Chr( 34 ) & "width:270; " & Chr( 34 ) & ">"
        sTemp = sTemp & "<option value=" & Chr( 34 ) & Chr( 34 ) & "></option>"
        For i = 0 to Ubound(aCountri es)
        sTemp = sTemp & "<option value=" & Chr( 34 ) & aCountryOptions (i) & Chr( 34 ) & ">" & aCountries(i) & "</option>"
        Next
        Set oCountries = Nothing
        Set oCountryOptions = Nothing
        Set oFileStream = Nothing
        CreateCountries = sTemp
        End Function
        [/code]
        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.
        Last edited by jhardman; Aug 28 '07, 07:57 PM. Reason: put code in code tags. please use code tags in the future

        Comment

        • Ranjan kumar Barik
          New Member
          • Aug 2007
          • 95

          #5
          Originally posted by markrawlingson
          I wrote a nice little script that handles this.

          Below is the code...
          [code=asp]
          Function CreateCountries
          Set oFileStream = Server.CreateOb ject("Scripting .FileSystemObje ct")
          Set oCountries = oFileStream.Ope nTextFile(Serve r.MapPath("/platform/Countries.txt") , 1)
          aCountries = Split( oCountries.Read All, vbCRLF )
          oCountries.Clos e
          Set oCountryOptions = oFileStream.Ope nTextFile(Serve r.MapPath("/platform/CountryOptions. txt"), 1)
          aCountryOptions = Split( oCountryOptions .ReadAll, vbCRLF )
          sTemp = sTemp & "<select name=" & Chr( 34 ) & "sCountry" & Chr( 34 ) & " id=" & Chr( 34 ) & "sCountry" & Chr( 34 ) & " style=" & Chr( 34 ) & "width:270; " & Chr( 34 ) & ">"
          sTemp = sTemp & "<option value=" & Chr( 34 ) & Chr( 34 ) & "></option>"
          For i = 0 to Ubound(aCountri es)
          sTemp = sTemp & "<option value=" & Chr( 34 ) & aCountryOptions (i) & Chr( 34 ) & ">" & aCountries(i) & "</option>"
          Next
          Set oCountries = Nothing
          Set oCountryOptions = Nothing
          Set oFileStream = Nothing
          CreateCountries = sTemp
          End Function
          [/code]
          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 !!!!

          Comment

          • markrawlingson
            Recognized Expert Contributor
            • Aug 2007
            • 346

            #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

            Comment

            • Ranjan kumar Barik
              New Member
              • Aug 2007
              • 95

              #7
              Originally posted by markrawlingson
              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.

              Comment

              • markrawlingson
                Recognized Expert Contributor
                • Aug 2007
                • 346

                #8
                No problem, hope they come in handy for you :)

                Comment

                Working...