Forums

This topic is locked

Advanced Update Record Checkboxes "checked"

Posted 13 Aug 2003 23:23:46
1
has voted
13 Aug 2003 23:23:46 Erik Piisila posted:
I have dynamically generated a set of checkboxes from a recordset of "cards." I used the horizontal looper extension in ASP VB script. The end result is a four column table with a check box of value "cardid." In this case, there are 24 records.

The user selects whatever cards of the 24 and submits into another table of "cardsets."

This table has a "cardsetID" and comma separated string field of whatever cards they selected "selectedcards"


Anyone know how to split that "selectedcards" value and check it against the horizontal looper table of checkboxes of "cardid"s to dynamically make the "cardid" check boxes checked?

Any help is appreciated.

Replies

Replied 25 Aug 2003 16:14:20
25 Aug 2003 16:14:20 Erik Piisila replied:
Hey! Anyone Out There?

I emailed the creator of Horizontal Looper and never got a response. The following Code is how I getting the dynamic check boxes to appear checked on the UPDATE. Now I just need to format the results as nicely as Looper did on the INSERT record page

*******************************
UPDATE CODE
********************************

<% 'START OF CODE NEED FOR CHECKBOXES TO WORK WITH DREAMWEAVERMX RECORDSETS
dim strClean 'CLEAN UP ACCESS SELECTED VALUES ARRAYS (A, B, C,)
strClean = marketsets.Fields.Item("cardset".Value
strClean = Replace(strclean, ", ", ","

' END OF DREAMWEAVERMX SELECTED VALUES CLEANING OF COMMA SEPARATED VALUES %>

<% ' CREATE ARRAYS OF VALUES FOR CheckBOX
While (NOT cards.EOF)
dim strType1 ' Card Values in array

strType1 = strType1 & cards.Fields.Item("awmid".Value & "," ' Card Values in array

cards.MoveNext()
Wend
If (cards.CursorType > 0) Then
cards.MoveFirst
Else
cards.Requery
End If
%>
<% ' MANIPULATE ARRAYS FROM PREVIOUS STEP TO WRITE CheckBOX WITH SELECTED VALUES FROM ACCESS DATABASE COMMA SEPARATED VALUE
strSelection = strClean '"x,y,z" '* LIST OF RECORDED USER SELECTIONS FROM ACCESS IN CLEANED ARRAY
strSelection = "," & strSelection & "," '"," & strSelection & ","
strFull = strType1'"a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z" COMPLETE LIST OF POSSIBLE VALUES IN CREATED ARRAY
Dim arrFull, intEntry, strSelected
arrFull = split(strFull, "," 'Values
%>
<font size="1" face="Arial, Helvetica, sans-serif">
<%
For intEntry = lBound(arrFull) To uBound(arrFull)
if instr(strSelection,"," & arrFull(intEntry) & "," > 0 then
strSelected = "checked"
else
strSelected = ""
end if
%>
<input name="cardset" type="checkbox" id="cardset" value="<%=arrFull(intEntry)%>" <%=strSelected%>>
<%=arrFull(intEntry)%>
<%
Next
%>

****************************************
THIS CODE JUST LISTS CHECK BOXES
ONE AFTER THE OTHER ^^^^^^^^
*****************************************



*****************************************
BELOW IS CODE FOR HORIZONTAL LOOPER
ON INSERT PAGE. I WANT SAME FORMAT FOR UPDATE PAGE
*****************************************


<%
startrw = 0
endrw = HLooper1__index
numberColumns = 4
numrows = -1
while((numrows <> 0) AND (Not Cards.EOF))
startrw = endrw + 1
endrw = endrw + numberColumns
%>
<tr align="center" valign="top">
<%
While ((startrw <= endrw) AND (Not Cards.EOF))
%>
<td> <table width="150" border="0" cellspacing="0" cellpadding="0">
<tr valign="middle" bgcolor="#FFFFFF">
<td width="10" height="20"><font size="1" face="Arial, Helvetica, sans-serif">
<input name="cardset" type="checkbox" id="cardset" value="<%=(Cards.Fields.Item("AWMID".Value)%>" <%=strSelected%>>
</font></td>
<td><font size="1" face="Arial, Helvetica, sans-serif"> <a href="#" onClick="MM_openBrWindow('/admin/carddetail.asp?gif=<%=(Cards.Fields.Item("GIF".Value)%>','Cards','scrollbars=yes,width=310,height=400')"><%=(Cards.Fields.Item("AWMID".Value)%></a></font></td>
</tr>

</table></td>
<%
startrw = startrw + 1
Cards.MoveNext()
Wend
%>
</tr>
<%
numrows=numrows-1
Wend
%>
</table>



********************************
PLEASE HELP
********************************


Reply to this topic