|
-
Dec 19th, 2003, 10:39 AM
#1
Thread Starter
Junior Member
Multiple Select
I populate a field in my db with data from a multi select list box. This appears comma separated in the database field. My problem is that I need the user to be able to then edit the data at a later stage. To re-populate the list box I poulate an array and then if the value in the array matches an option in the list box, I set the SELECTED property in the HTML.
This is partially working and multiple values are selected if I have items that are next to each other in the list box. However if there is a gap between selected options, the one after the gap is not selected.
Any ideas?
Please find code below;
<%
'varString = "Paper, CD, Email"
varStart = 1
varEnd = 0
varLength = 0
blnWereCommas = False
ReDim varOption(9)
for x = 0 to 9
varoption(x) = " "
next
x = 0
'See if multiple values have been entered
intCount = InStr(varString, ",")
'If no comma's found, only one value entered.
If intCount = 0 Then
varOption(0) = varString
Else
blnWereCommas = True
varEnd = intCount
varLength = varEnd - 1
Do Until intCount = 0
x = x + 1
varOption(x) = Mid(varString, varStart, varLength)
varStart = varEnd + 1
intCount = InStr(varStart, varString, ",")
If intCount <> 0 Then
varEnd = intCount
varLength = varEnd - varStart
End If
Loop
End If
'No comma at the end of the Line, so get final choice.
If blnWereCommas = True Then
x = x + 1
varOption(x) = Mid(varString, varEnd + 1)
End If
For y = 0 To x
varOption(y) = Trim(varOption(y))
Next
IF varOption(0) = "Not Applicable" then Q9AOpt1 = "Selected" else Q9AOpt1 = "" end if
IF varOption(1) = "Paper" then Q9AOpt2 = "Selected" else Q9AOpt2 = "" end if
IF varOption(2) = "Disk" then Q9AOpt3 = "Selected" else Q9AOpt3 = "" end if
IF varOption(3) = "CD" then Q9AOpt4 = "Selected" else Q9AOpt4 = "" end if
IF varOption(4) = "Email" then Q9AOpt5 = "Selected" else Q9AOpt5 = "" end if
IF varOption(5) = "Post" then Q9AOpt6 = "Selected" else Q9AOpt6 = "" end if
IF varOption(6) = "Phone" then Q9AOpt7 = "Selected" else Q9AOpt7 = "" end if
IF varOption(7) = "Fax" then Q9AOpt8 = "Selected" else Q9AOpt8 = "" end if
IF varOption(8) = "Electronic Link" then Q9AOpt9 = "Selected" else Q9AOpt9 = "" end if
IF varOption(9) = "Other(please specify)" then Q9AOpt10 = "Selected" else Q9AOpt10 = "" end if
%>
<select size="1" name="Q9A" style="FONT-FAMILY: arial; HEIGHT: 150px; WIDTH: 350px; board-width: thin" multiple>
<option value="Not Applicable" <%=Q9AOpt1%>>Not Applicable
<option value="Paper" <%=Q9AOpt2%>>Paper
<option value="Disk" <%=Q9AOpt3%>>Disk
<option value="CD" <%=Q9AOpt4%>>CD
<option value="Email" <%=Q9AOpt5%>>Email
<option value="Post" <%=Q9AOpt6%>>Post
<option value="Phone" <%=Q9AOpt7%>>Phone
<option value="Fax" <%=Q9AOpt8%>>Fax
<option value="Electronic Link" <%=Q9AOpt9%>>Electronic Link
<option value="Other(please specify)" <%=Q9AOpt10%>>Other(please specify)
</option>
</select>
-
Dec 19th, 2003, 11:12 AM
#2
Thread Starter
Junior Member
Realised the problem is due to the fact that I'm not looping through the array at the end for each of the options. Oh yes, I forgot about using the Split function as well!!
Cheers
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|