Hello all
I'm having problems with generating a set of variables based on several
dynamic fields from the preceding template
basically it's like this:
the edit page generates a dropdown box for each category with the
category numbers listed in each box , but with the current status of
each selected. These boxes are generated based on how many categories
exist (there is a HIGH possibility in this app for more categories to be
added)
These dropdowns are named "importance1", "importance2", etc- the value
after the "importance" is generated dynamically based on what position
the category is ranked
code:
' the following code will determine the order which the article
categories are displayed
set ordercheck=Server.CreateObject("ADODB.recordset")
sqlorder="SELECT DISTINCT category, categoryimp FROM articles ORDER BY
categoryimp, category"
ordercheck.CursorLocation = 3
ordercheck.open sqlorder, Conn
ordercheck.movefirst
j=ordercheck("categoryimp")
response.write"<form action='temp.asp' method=post>"
response.write"<Table border=0 width=100% cellpadding=0
cellspacing=4 bgcolor=#666666>"
'--------code to generate drop down boxes for rankings---------
Do While NOT ordercheck.EOF
'reset j if it's greater than the total recordcount
if j > ordercheck.recordcount then
j=1
end if
response.write"<tr><td width=300px>"
response.write"<p class=content>"& ordercheck("category")& " Category
Ranking = "& ordercheck("categoryimp") &"<br></td>"
response.write"<td width=80% align=left>"
response.write"<select name="& chr(34) &"importance"&
ordercheck("categoryimp") & chr(34) &">"
for i=1 to ordercheck.recordcount
response.write"<option value="& chr(34) & j & chr(34)
if j = ordercheck("categoryimp") then
response.write" selected >"& j
else
response.write">"& j
end if
j=j+1
NEXT
response.write"</select></td></tr>"
ordercheck.movenext
loop
The next thing I wan to do is process this form by tepping through the
"importnace" fields till they are all out. I have thought up a couple of
ways to do this but they are all reliant on my ability to set a variable
like so: (syntax is totally wrong but regardless I can't set them this
way/)
FOR i=1 TO total ' total being the recordcount passed from
the previous page
var&i= request.form("importance"&i)
varcat&i=request.form("category"&i)
i=i+1
NEXT
and then create a loop to update the records for each category
sql=UPDATE articles SET categoryimp='"& var&i &"' WHERE
category='"& varcat&i &"'"
and then perform the UPDATE
IS there an easier way to do this. I'm having a tough time wrapping my
head around the logic of this one.
Thanks