i am fetching records from mysql database am using while loop for displaying in side while loop am using radio button for each record am using ajax for posting each radio button value
but it is not working properly
sql query is
=============== ===============
for posting radio button values am using following ajax code but it is not working
am new to ajax please solve this
thanks in advance
but it is not working properly
sql query is
Code:
<?php
//db connection
$query1=mysql_query("select * from questions ");
while($res1=mysql_fetch_array($query1))
{
?>
Q)<?php echo $res1['id'];?>
<b>
<?php echo $res1['question'];?>
</b>
<table>
<tr>
<td><input type="radio" name="ans<?php echo $res1['id'];?>" id="ans1" value="A"></td>
<td><strong>A</strong></td>
<td><?php echo $res1['answer1'];?></td>
</tr>
<input type="hidden" name="id" id="id" value="<?php echo $res1['id'];?>">
<tr>
<td ><input type="radio" name="ans<?php echo $res1['id'];?>" id="ans2" value="B"></td>
<td><strong>B</strong></td>
<td><?php echo $res1['answer2'];?></td>
</tr>
<tr>
<td><input type="radio" name="ans<?php echo $res1['id'];?>" id="ans3" value="C"></td>
<td><strong>C</strong></td>
<td><?php echo $res1['answer3'];?></td>
</tr>
</table>
<?php
}
?>
for posting radio button values am using following ajax code but it is not working
Code:
$.ajax({
type: "POST",
url: "count.php",
dataType: "json",
data: "id="+id+"&ans1="+ans1,
cache:false,
success:
function(data){
if(id==100)
{
window.location = 'score.php';
opener.Reload();
}
else {
document.getElementById("statediv").innerHTML = "";
$("#statediv").append(data);
$("#form_message").html(data.message).css({'background-color' : data.bg_color}).fadeIn('slow');
}
}
});
return false;
});
});
am new to ajax please solve this
thanks in advance
Comment