<select> controls and multiple values...

Results 1 to 3 of 3

Thread: <select> controls and multiple values...

  1. #1
    Join Date
    Dec 1969

    Default <select> controls and multiple values...

    ...I have successfully added / allowed multiple values to be selected and written to a database. Now my problem is selecting (SELECTED) all of those values when a user wants to edit the list.<BR><BR>I need to show all the ones as selected and can&#039;t figure out the best way to approach this.

  2. #2
    Join Date
    Dec 1969
    Los Angeles, CA

    Default A few ways

    As you populate the list in a loop, if that option in in the list of options selected you jsut set the keywork selected<BR><BR>or you can select the keywork selected in the SQL statement itself<BR>

  3. #3
    Join Date
    Dec 1969

    Default Depends on HOW you did this...

    Did you put all the values into a delimited list and store that list in a single field in a single record?<BR><BR>Or did you properly create *another* table just for this set of multiple values?<BR><BR>If the latter, you can do it all in SQL.<BR><BR>Say that you have this table structure:<BR><BR>Table: Users<BR> userID : PK<BR> userName : text<BR> ...<BR><BR>Table: Foods<BR> foodID : PK<BR> foodName : text<BR><BR>Table: FoodPreferences<BR> userID : Foreign key to Users<BR> foodID : Foreign key to Foods<BR><BR>Then you can do:<BR><BR> SELECT F.foodID, F.foodName, IIF( IsNull( FP.userID ), &#039; &#039;, &#039; SELECTED &#039; ) AS sel<BR> FROM Foods AS F LEFT JOIN FoodPreferences AS FP<BR> ON ( F.foodID = FP.foodID AND FP.userID = ### )<BR> ORDER BY F.foodName<BR><BR>And if you create a RS using that, then:<BR><BR>&#060;%<BR>Do Until RS.EOF <BR>%&#062;<BR> &#060;OPTION Value="&#060;%=RS("foodID")%&#062;" &#060;%=RS("sel")%&#062; &#062; &#060;%=RS("foodName")%&#062;<BR>&#060;%<BR> RS.MoveNext<BR>Loop<BR>%&#062;<BR><BR>See it? If not, ask.<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