Hi guys, I have a problem on getting the selected radio button and save it in the database.
Here is my code:
<div id="container">
<div id="question1" style="display: inline;">
<p>Question 1</p>
<ul>
<li><input type="radio" name="q1" value="1" id="ans1" />Answer 1</li>
<li><input type="radio" name="q2" value="2" id="ans1"/>Answer 2</li>
<li><input type="radio" name="q3" value="3" id="ans1"/>Answer 3</li>
</ul>
</div>
<div id="question2" style="display: none;">
<p>Question 2</p>
<ul>
<li><input type="radio" name="q1" value="1" id="ans2" />Answer 1</li>
<li><input type="radio" name="q2" value="2" id="ans2"/>Answer 2</li>
<li><input type="radio" name="q3" value="3" id="ans2"/>Answer 3</li>
</ul>
</div>
<div id="question3" style="display: none;">
<p>Question 3</p>
<ul>
<li><input type="radio" name="q1" value="1" id="ans3" />Answer 1</li>
<li><input type="radio" name="q2" value="2" id="ans3"/>Answer 2</li>
<li><input type="radio" name="q3" value="3" id="ans3"/>Answer 3</li>
</ul>
</div>
</div><!-- END OF CONTAINER -->
and my javascript:
<script src="jquery-1.6.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
$('#container #ans1').click(function(){
$('question1').css('opacity',1);
$('question2').css('opacity',0);
$('question3').css('opacity',0);
});
$('#container #ans2').click(function(){
$('question1').css('opacity',0);
$('question2').css('opacity',1);
$('question3').css('opacity',0);
});
$('#container #ans3').click(function(){
$('question1').css('opacity',0);
$('question2').css('opacity',0);
$('question3').css('opacity',1);
});
</script>
I wanted to know which answers are selected and save those answers in the database with the corresponding question. :sad: I am using MYSQL as my database tool. I know how to use MYSQL and querying :) but I just don't know how to get the datas that I need.:confused:
Please help me on this one.. Thanks :X