Click to See Complete Forum and Search --> : How do I show or hide DIV based on ASP field value?


Low Society
11-01-2009, 06:27 PM
Hi,
I have created a user form in which visitors can fill in sections, some of which are hidden or displayed using the onclick to trigger a DIV to display or hide then submit the results to a database using ASP. All works fine with that, however...

I have created another page which retrieves the results for an individual's form submission, and I want to hide the sections that were not completed (hidden when submitted).

How can I get my page to hide or show DIVs, depending on the value retrieved from a particular field within the database?

i.e. if Question1Response="A", show Div ID="A Section"
If Question1Response="B", show Div ID="B Section" etc.

Hope this makes sense. Any help would be gratefully received.

Thanks,
Low Society

gil davis
11-05-2009, 07:27 AM
<%
function showDiv(ans)
if Question1Response = ans then
showDiv = "inline" ' or block
else
showDiv = "none"
end function %>
<div id="A_Section" style="display: <%=showDiv("A")%>">
...
</div>
BTW, I don't think it is valid to use identifiers containing the space character in HTML.

Low Society
11-05-2009, 06:31 PM
Thank you very much for your help. I won't get the opportunity to try your solution until next week, but I'm encouraged by your suggested solution to my problem.

I really appreciate your help. Thanks again,
Gary