How do I get the value of id="question_type_' + count + '"?
I'm having some trouble with getting the value of my radio buttons here:
http://testing.feministbitch.com/index.php/quiz_creator. I have the full code at the very bottom.
When you click add question, I made it so that people can choose the following radio buttons:
true/false or
multiple choice.
I'm trying to do this: Based on whether they choose
true/false or
multiple choice, further radio buttons or inputs+drop downs would come down underneath the question.
But i'm failing. Please help me :).
The problem here is that I don't know what to set
var x equal to get the
true_false value or
multiple_choice value.
I tried, but these didn't work.
- //var x = $("#question_type"+count).value;
- //var x=document.forms["quizquiz"]["question_type" + count].value;
Here's the part in my code that appends the true/false stuff or multiple stuff based on what radio button they picked:
- if (x=="true_false"){
- $('#container').append(
- 'The above statement is '+ '<Input id="true_or_false_' + count + '" type = "Radio" Name ="true_or_false[]" value= "true">' + 'True' + ' '
- + '<Input id="true_or_false_' + count + '" type = "Radio" Name ="true_or_false[]" value= "false">'+ 'False<br /><br/>'
- );
- }else{
- $('#container').append(
- 'A: ' + '<input id="multi_choices_' + count + '" name="multiple_choices[]' + '" type="text" maxlength="300" size="150"/><br />' +
- 'B: ' + '<input id="multi_choices_' + count + '" name="multiple_choices[]' + '" type="text" maxlength="300" size="150"/><br />' +
- 'C: ' + '<input id="multi_choices_' + count + '" name="multiple_choices[]' + '" type="text" maxlength="300" size="150"/><br />' +
- 'D: ' + '<input id="multi_choices_' + count + '" name="multiple_choices[]' + '" type="text" maxlength="300" size="150"/><br />' + '<br />'
- +'Correct Choice: '
- +'<select name="correct_choice[]">'
- +'<option value="A">A</option>'
- +'<option value="B">B</option>'
- +'<option value="C">C</option>'
- +'<option value="D">D</option>'
- +'</select>'
- +'<br /><br />'
- );
- }
Here's the full code for the page: