<SELECT> Question

Results 1 to 2 of 2

Thread: <SELECT> Question

  1. #1
    Join Date
    Dec 1969

    Default <SELECT> Question

    I have been thinking of how I could do this, but have not come to a conclusion yet :)<BR><BR>I want to be able to have dropdown boxes that are selected on a particular &#060;OPTION&#062; based on a DB. I know you can select them by default by going &#060;OPTION value="value" SELECTED&#062; . But I am not sure how I would select a certain option tag based on a DB. I suppose you would have to store the value of each option into a varible and then compare it with the DB field. My option tags are recieved through a text file. Using this code to grab the file and output the option tags.<BR><BR>&#060;SELECT name="model"&#062;<BR>&#060;%<BR> Dim sPath, oFSO, oFile, oTextStream <BR><BR> sPath = Server.MapPath("INCS/" & sMake & ".inc") <BR><BR> Set oFSO = Server.CreateObject("Scripting.FileSystemObject")< BR><BR> Set oFile = oFSO.GetFile(sPath)<BR><BR> Set oTextStream = oFile.OpenAsTextStream(1)<BR><BR> Response.Write(oTextStream.ReadAll) <BR><BR> Set oFSO = Nothing<BR> Set oFile = Nothing<BR> Set oTextStream = Nothing<BR> %&#062;<BR>&#060;/SELECT&#062;<BR><BR>Any ideas?

  2. #2
    Join Date
    Dec 1969

    Default ASPFAQs, category Databases, General

    Yeah, it&#039;s not obvious. But see the FAQ on using GETSTRING to see how you can do this.<BR><BR>It won&#039;t matter whether you get the string of options from GETSTRING or from your file read, the REPLACE trick will work the same way.<BR><BR>I *do* have to question your use of a text file, though. That&#039;s going to be a performance hit. If these options don&#039;t change often, I&#039;d read the text file into an Application variable and then just get the string from that App variable. Tons faster.<BR><BR>Ummm...I just realized you are getting one of many files. Hmmm... Yeah, I think I&#039;d still read all the text files into app variables, one app variable per file contents. And then it&#039;s just:<BR><BR>&#060;%<BR>options = Application(sMake)<BR>options = Replace( options, ..., ... )<BR>Response.Write options<BR>%&#062;<BR><BR>No slow files to muck with except at app start up time.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts