My for loop in php looks like this:
for ($i=1;$i<=10;$i++) {
?>
<input type="hidden" class="ThisQuestion" id="GetQuestion-<?php echo $i; ?>" value="<?php echo $i; ?>" />
<a href="javascript:void(0)" class="VerySmallFont">
<div class="SelectNumberBox <?php echo $NumberBoxClass; ?>"><?php echo $i; ?></div>
</a>
Now I want to extract value of $i from php to Jquery. Here's what I am doing in JS part for this -
<script type="text/javascript" language="javascript">
$(document).ready(function() {
$(".VerySmallFont").click(function(){
var $Parent = $(this).parent();
var ThisQuestionNumber = $Parent.find('[id^="GetQuestion-]:first').val();
var TestID = $("#GetTestID").val();
var ShowCQ = '1';
$.ajax( {
type : 'GET',
url:'getquestiondata.php',
data : {TestID: TestID, ShowCQ: ShowCQ, ThisQuestionNumber: ThisQuestionNumber},
success:function(data) {
$("#LoadingImage").hide();
$('#ShowQuestion').html(data);
}
});
});
});
</script>
I'm not getting value of the var ThisQuestion in my JS. I also tried using the class ThisQuestion instead of id selector GetQuestion but that doesn't work either. I'm not sure what the mistake that I'm making is.