<script language=vbscript>
sub NewDropdown(fieldid, myarray)
'Set objList = Document.frmUserProfile.Item(0)
Set objList = document.getElementById(fieldid)
Set objOption = Document.CreateElement("OPTION")
objOption.InnerHTML = "Chicken"
objList.AppendChild(objOption)
Set objOption = Document.CreateElement("OPTION")
objOption.InnerHTML = "Potatoes"
objList.AppendChild(objOption)
Set objOption = Document.CreateElement("OPTION")
objOption.InnerHTML = "Milk"
objList.AppendChild(objOption)
document.getElementById(fieldid).style.visibility = "Visible"
end sub
</script>
<%
%>
<form action="<%=request.Servervariables("URL")%>" name="frmUserProfile" method="post" ID="Form1">
<table width=100% border=0 cellpadding=0 cellspacing=1 ID="Table2">
<tr><td colspan=4 align=left> </td></tr>
<%
x = 0
strSQL_DemogAnswers = "select * from id0_request_answers_child "
set rsAC = conn.Execute(strSQL_DemogAnswers)
if not rsAC.eof then
do while not rsAC.eof
Redim Preserve RS_Array(6, x + 1)
RS_Array(1,x + 1) = rsAC("Child_ID")
RS_Array(2,x + 1) = rsAC("Answer_ID")
RS_Array(3,x + 1) = rsAC("Question_ID")
RS_Array(4,x + 1) = rsAC("Child_Text")
RS_Array(5,x + 1) = rsAC("Display_Order")
RS_Array(6,x + 1) = rsAC("Active")
i = i + 1
rsAC.movenext
loop
end if
i=1
Do while not rsGQ.EOF
'//sets up the table for all elements that are not associated with Height
%><tr align=right ><td><span class="fieldTitle"> <%=rsGQ.Fields("question_text")%> </span></td>
<td align=left><%
'//Retrieves the next set of answers from the database
'//it also retrieves any answers that were provided by the user
strSQL_DemogAnswers = "SELECT ANSWER_TEXT, ANSWER_ID "
'//This query was originally set up to get one answer from the user per question
'//with the checkboxes the user can enter multiple answers, this caused an error.
If rsGQ.Fields("RESPONSE_TYPE") <> "checkbox" then
strSQL_DemogAnswers = strSQL_DemogAnswers & " , (Select demog_answer_id from TBL_DEMO_USER_ANSWERS " & _
" WHERE user_id = "&UserID&" and demog_question_id=" & rsGQ.Fields("QUESTION_ID") & ") as DUA "
End if
strSQL_DemogAnswers = strSQL_DemogAnswers & " FROM id0_request_answers t Where t.QUESTION_ID = " & rsGQ.Fields("QUESTION_ID") & " " & _
" ORDER BY ANSWER_TEXT ASC "
'response.Write strSQL_DemogAnswers
set rsGA = conn.Execute(strSQL_DemogAnswers)
IF 0 <> Err.number THEN
'// the requested form was not in the database.
bMinorError = TRUE
END IF
'if i > 4 then response.End
%>
<SELECT name="<%=rsGQ.Fields("FORM_FIELD_NAME")%>" id=<%=i%> onChange="NewDropdown(<%=i+1%>, <%RS_Array%>)"><%
%><option value=-1>Select...</option><%
Do while not rsGA.EOF
if not isnull(rsGA("DUA")) and rsGA("DUA")<> "" then
UserAnswer = rsGA("DUA")
else
UserAnswer = 0
End If
if cdbl(rsGA("ANSWER_ID")) = cdbl(UserAnswer) then
%><option value="<%=rsGA.Fields("ANSWER_ID")%>" selected><%=rsGA.Fields("ANSWER_TEXT")%></option><%
Else
%><option value=<%=rsGA.Fields("ANSWER_ID")%>><%=rsGA.Fields("ANSWER_TEXT")%></option><%
end if
rsGA.MoveNext
loop
%>
<option value=0>Other</option>
</select>
<%
i = i + 1%>
<select id=<%=i%> name="<%=rsGQ.Fields("FORM_FIELD_NAME")%>child" style="visibility: hidden;"></select>
<%
i = i + 1
rsGQ.MoveNext
%></td></tr><tr><td colspan=2> </td></tr><%
set rsGA = nothing '//Close the connection string for the System Demographic Answers
Loop
set rsGQ = nothing '//Close the connection string for the System Demographic Questions
%>