Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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
--------------------------------------------------------------------------

Posted

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.

  • Moderators
Posted

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.

Visit...Bassic Software
Posted
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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...