Hi cube, thanks for the advice. I just have time to try out the code today.
But I think I am more clear what the problem I have now.
Let me explain, I do have two pages as croCrew said.
The first page has a display of a subscription list.
- set rs3=Server.CreateObject("ADODB.Recordset")
-
sql = "select * from contact_options c inner join options o on c.option_uid=o.uid where contact_uid=" & request("contact")
-
rs3.open sql, conn
-
i=1
-
response.write "<table>"
-
response.write "<tr><th align='left'>Subscription List</th><td><a href='subscription.asp?contact=" & request("contact" )& "'>Edit</a></td></tr>"
-
do while not rs3.eof
-
response.write vbcrlf & "<tr><td>" & i & ". " & rs3("option_name") & "</td>"
-
response.write vbcrlf & "<td></td></tr>"
-
rs3.movenext
-
i = i + 1
-
loop
-
response.write "</table>"
-
rs3.close
-
end if
Then the edit page will pass through the contact id to the subscription.asp.
Contact id then will look up the contact_options to find which subscription this contact has.
The subscription page then shall display all the subscription options (from the options table) except for those are in the database (contact_options table) already. This is my target.
On this page, I tried to store the existing option uid in an array and compare to the rest of the available subscription options according to their uid.
But if the array number stores only 1 value which is 3, the html will display all the options again start from 1 to 6. It does not make the option 3 disappeared.
So, I suspect some where in my loop condition is not quite rite in the second part of the if statement; which is the following.
-
'select all the data
-
sql = "select * from contact_options c inner join options o on c.option_uid=o.uid where contact_uid=" & request("contact")
-
rs2.open sql, conn
-
-
dim a(6)
-
i=0
-
Do while not rs2.eof
-
a(i)= rs2("option_uid")
-
'response.write rs2("option_uid") & "<br />"
-
rs2.movenext
-
i= i +1
-
loop
-
rs2.close
-
-
'select options
-
sql = "select * from options"
-
rs.open sql, conn
-
%>
-
<form name="myform" action='subscription.asp' method='post'>
-
<input type='hidden' name='contact' value='<%=request("contact")%>' />
-
<table>
-
<%
-
b = 0
-
Do while not rs.eof
-
if rs("uid")<>a(b) then
-
response.write "<tr><td><input type='checkbox' name='check_list' value='" & rs("uid") & "' ></td>"
-
response.write "<td><b>" & rs("option_name") & "</b></td></tr>"
-
b = b + 1
-
else
-
response.write "<tr><td><input type='checkbox' name='check_list' value='" & rs("uid") & "' disabled></td>"
-
response.write "<td><b>" & rs("option_name") & "</b></td></tr>"
-
b = b + 1
-
End if
-
rs.movenext
-
loop
-
%>
-
<!-- <tr><td>
-
<input type="checkbox" name="Check_ctr" value="yes" onClick="Check(document.myform.check_list)">
-
</td><td><b><i>Check All</i></b></td></tr>-->
-
<tr><td> </td><td>
-
<input type="Submit" name="Submit" value="Submit">
-
</td></tr>
-
</table>
-
</form>
-
<%
-
rs.close
-
-
Will be very appreciated if I could spare some smartness here to solve the problem. Thanks :)