vbFace Posted January 8, 2004 Posted January 8, 2004 Let's say I have an on-line questionnaire. Say a page has 10 sets of RadioButtons. The radio buttons are named "RadioQ1", "RadioQ2", etc. Is there a way to randomize the order that the radio button groups show up on the page each time someone visits the page? The radio button names represent the question number and are hard-coded in the page (RadioQ1 is for question #1, etc). The button groups are in an HTML table with the text of the question to the left of the radio buttons: HTML Table: -------------------------------------------------------------------------- | Question#1 text | 0 Opt One 0 Opt Two 0 Opt Three | <-- RadioQ1 | Question#2 text | 0 Opt One 0 Opt Two 0 Opt Three | <-- RadioQ2 | Question#3 text | 0 Opt One 0 Opt Two 0 Opt Three | <-- RadioQ3 | Question#4 text | 0 Opt One 0 Opt Two 0 Opt Three | <-- RadioQ4 | Question#5 text | 0 Opt One 0 Opt Two 0 Opt Three | <-- RadioQ5 -------------------------------------------------------------------------- So the question text must follow with the radomized radio buttons to look like: HTML Table: -------------------------------------------------------------------------- | Question#3 text | 0 Opt One 0 Opt Two 0 Opt Three | <-- RadioQ3 | Question#2 text | 0 Opt One 0 Opt Two 0 Opt Three | <-- RadioQ2 | Question#4 text | 0 Opt One 0 Opt Two 0 Opt Three | <-- RadioQ4 | Question#5 text | 0 Opt One 0 Opt Two 0 Opt Three | <-- RadioQ5 | Question#1 text | 0 Opt One 0 Opt Two 0 Opt Three | <-- RadioQ1 -------------------------------------------------------------------------- Quote
Moderators Robby Posted January 8, 2004 Moderators Posted January 8, 2004 Instead of randomizing the controls why not randomize the questions. Quote Visit...Bassic Software
vbFace Posted January 8, 2004 Author Posted January 8, 2004 Each selection of the RadioButtonGroup is going to go into the DB with the appropriate, pre-determined Question Number. So, RadioQ3 will be coded to INSERT into the database table with a value of "3" for field QuestionNumber. The question number text has to relate to the question number. If I just randomize the questions, reporting will not be accurate, because different intended answers will be given for the same real-life question. Ex. If I randomize the Question Text, you may answer "Do you like our company" as Question 1 with an answer of 4. I may have "Do you like Product X" as the first question and give an answer of 1. The DB will have Question 1 = 4 for you and Question 1 = 1 for me. But we answered different questions. Quote
Moderators Robby Posted January 8, 2004 Moderators Posted January 8, 2004 My idea is to load a multi-dim array with the questions (including the ID field from the table) then randomize the order of the array, load the controls. When it's time to save the answers simply make a reference to the ID element in the array. This way you shouldn't care what you name the controls nor their order of appearance. Quote Visit...Bassic Software
vbFace Posted January 8, 2004 Author Posted January 8, 2004 Ahhhhh, I see. Nice. One quick question: As I am a child of ADO, and haven't used arrays except as quick storage, how would I randomize an array? The part of loading the controls dynamically should have lots of posts, so I'll search for that. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.