Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Arrays And Radio/Check Options 1

Status
Not open for further replies.

OrWolf

MIS
Mar 19, 2001
291
I'm creating a survey and want to have the user input via check boxes or radio buttons. Since the number of answers vary, I was going to use an array to create the options. Below is the portion of the code applicable to what I want to use. However I'm completely stumped on how to populate the form options. Any suggestions on the syntx would be greatly appreciated.

aSQL="SELECT RA_SurveyAnswers.AnswerID, RA_SurveyAnswers.PossibleAnswer " & _
"FROM RA_SurveyAnswers WHERE (((RA_SurveyAnswers.RAS_ID)=" & iRASID & "))"

Set rs2 = objConnection.Execute(aSQL)

arrAnswerID = Array(rs2("AnswerID"))
arrAnswer = Array(rs2("PossibleAnswer"))
 
Hi,

There are diferences between radio buttons and check boxes!
Each radio-button control in the group should be given the same name. Only the selected radio button in the group generates a name/value pair in the submitted data. Radio buttons require an explicit value property.
(Check box) This element is represented by a number of check box controls, each of which has the same name. Each selected check box generates a separate name/value pair in the submitted data, even if this results in duplicate names. The default value for check boxes is on.
The following code is for radio buttons:
Code:
<%
  do until rs2.EOF
%>
<input type=radio name=Answer value=&quot;<% =rs2(&quot;AnswerID&quot;) %>&quot;><% =Server.HTMLEncode(rs2(&quot;PossibleAnswer&quot;)) %><br>
<%
    rs2.MoveNext
  loop
%>

Regards,
Luís Silva
 
Thanks for the help. It worked like a charm. However, know I'm wondering how I can extract the information input in the following ASP page to use in a SQL statement to feedback into a database. I tried using the following to reference it, but it came back with all null values. I tested each value seperately using test data and 2 of 5 have values.


aSQL=&quot;SELECT RA_SurveyAnswers.AnswerID &quot; & _
&quot;FROM RA_SurveyAnswers WHERE (((RA_SurveyAnswers.RAS_ID)=&quot; & iRASID & &quot;))&quot;

Set rs2 = objConnection.Execute(aSQL)
Do While Not rs2.EOF
iAnswerID = rs2(&quot;AnswerID&quot;)
Answer = Request.Form(&quot;'&quot;&iAnswerID&&quot;'&quot;)
(SQL string here)
rs2.MoveNext
Loop
 
Hi again,

Sorry, I'm not really understanding what you really want, but if you used the same code I wrote you must use
Code:
Answer = Request.Form(&quot;Answer&quot;)
and not
Code:
Answer = Request.Form(&quot;'&quot;&iAnswerID&&quot;'&quot;)
as you did.
When you use Request.Form you must fill it with a variable name (input name, select name, etc) of the previous form.
Hope I've helped.

Regards,
Luís Silva
 
I used check boxes, so the survey page is dynamic. I'll have two to five or six possible answers per question. If I just refer to 'Answer' then I'll only end up with one . . . right?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top