Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Showing Multiple Selected items as highlighted in listbox 1

Status
Not open for further replies.

puterdude

Technical User
Apr 13, 2001
51
0
0
US
Hi,
I had gotten some help on this previously but I'm still not able to figure it out.

I have the following listbox (I abbreviated it for the forum) with all 50 states.

I allow for multiple selection. When a user clicks more than one state they are highlighted (if ctrl is down). That works. It stores the multiple data just fine.
What I want to do is have the user come back to the same record and view his previous selections. I would like them to be highlighted as they were when chosen.
Can someone please tell me where and how to do this? Thank you.

<td align=&quot;right&quot; width=&quot;180&quot;>
<div align=&quot;center&quot;>
<select name=&quot;states&quot; size=&quot;1&quot; multiple>
<option value=&quot;&quot; selected>Choose a State</option>
<option value=&quot;AL&quot;>Alabama</option>
<option value=&quot;AK&quot;>Alaska</option>
<option value=&quot;WV&quot;>West Virginia</option>
<option value=&quot;WI&quot;>Wisconsin</option>
<option value=&quot;WY&quot;>Wyoming</option>
</select>
</div>
</td>
</tr>
<tr>
<td align=&quot;right&quot; width=&quot;180&quot;>
<div align=&quot;right&quot;></div>
</td>
</tr>
<tr>
<td width=&quot;180&quot;>
<input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;Submit&quot;>
<input type=&quot;reset&quot; name=&quot;Reset&quot; value=&quot;Reset&quot;>
</td>
</tr>
</table>
<input type=&quot;hidden&quot; name=&quot;MM_update&quot; value=&quot;true&quot;>
<input type=&quot;hidden&quot; name=&quot;MM_recordId&quot; value=&quot;<%= RS_update.Fields.Item(&quot;Qid2&quot;).Value %>&quot;>
</form>
<p>&nbsp;</p>
</body>
</html>
 
One way to do it would be this:
1) Determine if the user has been on this page already or not. Have a variable that holds the selected states (varState). Use that to determine which states to mark as selected.

<select name=&quot;states&quot; size=&quot;1&quot; multiple>
<option value=&quot;&quot; <%if Len(varState)=0 then Response.Write(&quot;Selected&quot;) End if%>>Choose a State</option>
<option value=&quot;AL&quot; <%if InStr(varState,&quot;AL&quot;)<>0 then Response.Write(&quot;Selected&quot;) End if%>>Alabama</option>
<option value=&quot;AK&quot;<%if InStr(varState,&quot;AK&quot;)<>0 then Response.Write(&quot;Selected&quot;) End if%>>Alaska</option>
<option value=&quot;WV&quot;<%if InStr(varState,&quot;WV&quot;)<>0 then Response.Write(&quot;Selected&quot;) End if%>>West Virginia</option>
<option value=&quot;WI&quot;<%if InStr(varState,&quot;WI&quot;)<>0 then Response.Write(&quot;Selected&quot;) End if%>>Wisconsin</option>
<option value=&quot;WY&quot;<%if InStr(varState,&quot;WY&quot;)<>0 then Response.Write(&quot;Selected&quot;) End if%>>Wyoming</option>
</select>

So if varState=AL,AK,WY then Alabama, Alaska and Wyoming should be selected.

I hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top