Forums

ASP

This topic is locked

SET Datatype MySQL and ASP

Posted 07 Feb 2005 13:24:37
1
has voted
07 Feb 2005 13:24:37 Matt Jukes posted:
Hello,

I am working with the SET datatype in one column of a Mysql Database.

I have managed to select and split the entries in the SET column and show them inside a multi select form field, I have included the coding for the form field below.

<select name="genre" size="6" class="adminTextarea" multiple>
<%
For intSetCount = LBound(strSetNames) To UBound(strSetNames)
For intGenreCount = LBound(strGenreNames) To UBound(strGenreNames)
If strGenreNames(intGenreCount) = strSetNames(intSetCount) Then strSelected = " selected" _
Else strSelected = ""
Next
%>
<option value="<%=strSetNames(intSetCount)%>"<%=strSelected%>><%=strSetNames(intSetCount)%></option>
<% Next %>
</select>

As I am sure you're aware I would like to have all entries selected in the database highlighted in the list.

However when I look at the field I only seem to manage to highlight the last entry selected in the database and not all the entries.

I understand this is probably a problem with my FOR LOOP but i cannot pin-point where and why.

Any help with this would be great, Thanks in advance.

Matt

Replies

Replied 08 Feb 2005 11:49:52
08 Feb 2005 11:49:52 Lee Diggins replied:
Hi Matt

Bit of a bugger this one, anyway I've created a test page here for you to play with, works 100% <img src=../images/dmxzone/forum/icon_smile_big.gif border=0 align=middle>.

You'll see I've setup two test arrays using your code, post back if you get stuck:

&lt;%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%&gt;
&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "www.w3.org/TR/html4/loose.dtd"&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"&gt;
&lt;title&gt;Untitled Document&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;%
Dim strSetNames(10), strGenreNames(7), i, iOut

Response.Write("&lt;b&gt;strSetNames Array&lt;/b&gt;&lt;br&gt;"
For i = LBound(strSetNames) To UBound(strSetNames)
strSetNames(i) = "ItemLabel" & i
Response.write(strSetNames(i) & ", "
Next
%&gt;
&lt;hr&gt;
&lt;%
Response.Write("&lt;b&gt;strGenreNames Array&lt;/b&gt;&lt;br&gt;"
For iOut = LBound(strGenreNames) To UBound(strGenreNames)
strGenreNames(iOut) = "ItemLabel" & iOut
Response.write(strGenreNames(iOut) & ", "
iOut = iOut + 1
Next
%&gt;
&lt;hr&gt;
&lt;select name="genre" size="6" class="adminTextarea" multiple&gt;
&lt;% For intSetCount = LBound(strSetNames) To UBound(strSetNames)
%&gt;
&lt;option value="&lt;%=strSetNames(intSetCount)%&gt;"
&lt;%
For intGenreCount = LBound(strGenreNames) To UBound(strGenreNames)
If strGenreNames(intGenreCount) = strSetNames(intSetCount) Then
Response.Write(" selected"
End If
Next
%&gt;&gt;&lt;%=strSetNames(intSetCount)%&gt;&lt;/option&gt;
&lt;% Next %&gt;
&lt;/select&gt;
&lt;/body&gt;
&lt;/html&gt;

Sharing Knowledge Saves Valuable Time!!!
~ ~ ~ ~ ~ ~
Lee Diggins - <i>DMXzone Manager</i>
<font size="1">[ Studio MX/MX2004 | ASP -> VBScript/PerlScript/JavaScript | SQL | CSS ]</font>
Replied 08 Feb 2005 14:10:06
08 Feb 2005 14:10:06 Matt Jukes replied:
Thanks Lee,

That Worked Superbly.
You're Right if it wasn't for great people like you helping me save time, i'd never get anything done.

Matt
Replied 08 Feb 2005 14:39:33
08 Feb 2005 14:39:33 Lee Diggins replied:
Hi Matt

Glad to have helped.

<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>You're Right if it wasn't for great people like you helping me save time, i'd never get anything done. <hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Thanks Matt, I don't think I'm in the 'Great' class yet though <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>

Sharing Knowledge Saves Valuable Time!!!
~ ~ ~ ~ ~ ~
Lee Diggins - <i>DMXzone Manager</i>
<font size="1">[ Studio MX/MX2004 | ASP -> VBScript/PerlScript/JavaScript | SQL | CSS ]</font>

Reply to this topic