Multiple Selection Box Problem

Results 1 to 3 of 3

Thread: Multiple Selection Box Problem

  1. #1
    James Barrett Guest

    Default Multiple Selection Box Problem

    Hi all,<BR><BR>I have created an ASP form that reads and writes data to an SQL DB. The problem that I&#039m having is this:<BR><BR>I have 3 multiple select boxes on the form. I have an Edit page to update the records but I can&#039t find a way to have the Multiple Selection Box populated with the data from the DB when you come to edit the record.<BR><BR>I.E. You created a record, say - you choose 3 colours from a multiple selection box and you submit the form, no problem. You then decide you want to change the 3 colours you selected so you go to the edit page but the Multiple Selection Box does not highlight the previous seletions you made.<BR><BR>Sorry for the long winded style of this message.<BR><BR>TIA<BR><BR>James <BR> <BR><BR> <BR>

  2. #2
    KPW Guest

    Default RE: Multiple Selection Box Problem

    Well, I&#039ll give it a shot. My experience is with Access, so you will have to adapt this if necessary.<BR><BR>OK, suppose you have stored your color names in a single field, with each color name separated by a comma. When you go to modify the page, first assign the value of this field to a variable.<BR><BR>So, for example,<BR><BR>&#060;%<BR>sColors = rs.Fields("colors")<BR>%&#062;<BR><BR>If the field "colors" contained "red,green,blue", then sColors would now be "red,green,blue".<BR><BR>OK, now for each color that the user could choose, you will want to check if that color is in sColors.<BR><BR>&#060;%<BR>Dim bRed<BR>Dim bGreen<BR>Dim bBlue<BR>Dim bBlack<BR>Dim bYellow<BR>Dim bCyan<BR>Dim bMagenta<BR>Dim bWhite<BR><BR>bRed = false<BR>bGreen = false<BR>bBlue = false<BR>bBlack = false<BR>bYellow = false<BR>bCyan = false<BR>bMagenta = false<BR>bWhite = false<BR><BR>if InStr(sColors,"red") then bRed = true<BR>If InStr(sColors,"green") then bGreen = true<BR>If InStr(sColors,"blue") then bBlue = true<BR>If InStr(sColors,"black") then bBlack = true<BR>If InStr(sColors,"yellow") then bYellow = true<BR>If InStr(sColors,"cyan") then bCyan = true<BR>If InStr(sColors,"magenta") then bMagenta = true<BR>If InStr(sColors,"white") then bWhite = true<BR><BR>%&#062;<BR><BR>In our example, bRed, bGreen, and bBlue would now be true.<BR><BR>Finally, write out your select box.<BR><BR>&#060;SELECT name="cboColors" size="6" multiple&#062;<BR>&#060;option value="red"&#060;% if bRed then response.write " selected" %&#062;&#062;Red&#060;/option&#062;<BR>&#060;option value="green"&#060;% if bGreen then response.write " selected" %&#062;&#062;Green&#060;/option&#062;<BR>&#060;option value="blue"&#060;% if bBlue then response.write " selected" %&#062;Blue&#060;/option&#062;<BR>.................<BR>&#060;/SELECT&#062;<BR><BR>I don&#039t know if this is the best way of doing it, but it should get the job done. It is certainly the way I would do it.<BR><BR>I hope this helps!

  3. #3
    Buck Guest

    Default RE: Multiple Selection Box Problem

    James,<BR>I&#039m even in worse shape than you. How do you set up a multiple selection box in the first place? I am providing information about counties and would like to present up to five at one time instead of having to show them one at a time. Any suggestions?<BR><BR>Thanks,<BR>Buck

Posting Permissions

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