Forum Moderators: open

Message Too Old, No Replies

checkbox checked if in session array

         

brahm

4:21 pm on Sep 4, 2003 (gmt 0)

10+ Year Member



Hello,

I have created a recordset that diplays checkboxes all with the same name but have different values.

city = request.querystring("city")
city = Replace( city, ", ", "','" )
session("city") = city

Now when I revisit the page I would like the checkbox to be checked if the recordset("city") is found in session("city")

Can you explain to me what needs to be done.

Thanks
-Brahm

macrost

7:30 am on Sep 5, 2003 (gmt 0)

10+ Year Member



It might help if you posted a snippet of the code that is giving you problems... I can think of a couple ways to accommplish this, but without knowing exactly, well it'sa kinda harda to a do a ;)

Mac

brahm

4:03 pm on Sep 5, 2003 (gmt 0)

10+ Year Member



Below is the code where I am having a problem.

<%
if rs_city("city") = session("city") then
checked = "checked"
end if
%>
<input type="checkbox" name="city" value="<%=(rs_city("city"))%>" <%=checked%> >

the variable checked never = "checked" because the session("city") is an array. I need to know how to make the field rs_city("city") look to see if it is anywhere whithin the array.

I appreciate your help
Thanks
-Brahm

mattglet

5:01 pm on Sep 5, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



from what i can see in your first post, it isn't an actual "array" per se. it's more of a comma delimited value.

you could do this:

if (instr(1, session("city"), rs_city("city"), 1) > 0) then
checked = "checked"
end if

not sure how efficient that is without seeing the rest of your code, but i'm pretty sure it'll do the job.

-Matt

brahm

6:03 pm on Sep 5, 2003 (gmt 0)

10+ Year Member



Wow, that worked.

Thank you very much Matt.